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

Q&A's, tips, howto's

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

Postby ghyll » Wed Jun 10, 2015 3:19 am

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!
ghyll
 
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am

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

Postby ralph.ronnquist » Wed Jun 10, 2015 4:28 am

Maybe you overlook that directory only returns file base names, without the path prefix?
ralph.ronnquist
 
Posts: 204
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

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

Postby ghyll » Fri Jun 12, 2015 6:20 am

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 :)
ghyll
 
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron