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

Started by ghyll, June 09, 2015, 08:19:05 PM

Previous topic - Next topic

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.


(dolist (x (directory path))
        (rename-file x (trim x))
)


I tried debugging by using (trace true) with the following code:


(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!

rrq

#1
Maybe you overlook that directory only returns file base names, without the path prefix?

ghyll

#2
Quote from: "ralph.ronnquist"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 :)