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

Q&A's, tips, howto's
Locked
ghyll
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am

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

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

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

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

Post by ralph.ronnquist »

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

ghyll
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am

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

Post 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 :)

Locked