Page 1 of 1

do trailing spaces cause (file? x) to return nil?

Posted: Wed Jun 10, 2015 3:19 am
by ghyll
I have a few directories full of files named with trailing spaces. I thought this would remove the trailing spaces, but it only returns nil.

Code: Select all

(dolist (x (directory path))
        (rename-file x (trim x))
)
I tried debugging by using (trace true) with the following code:

Code: Select all

 (dolist (x (directory path)) 
   (file? x))
)
The "." and ".." files in the directory are files, but the other files return "nil". Does the trailing space prevent newLISP from recognizing the file as a file? Is there something else that may be causing the error (e.g. bad code on my part)? Thanks!

Re: do trailing spaces cause (file? x) to return nil?

Posted: Wed Jun 10, 2015 4:28 am
by ralph.ronnquist
Maybe you overlook that directory only returns file base names, without the path prefix?

Re: do trailing spaces cause (file? x) to return nil?

Posted: Fri Jun 12, 2015 6:20 am
by ghyll
ralph.ronnquist wrote:Maybe you overlook that directory only returns file base names, without the path prefix?
D'oh! You're completely correct. I forgot to move Terminal from my "newlisp" directory to where it should have been. Thank you :)