Submit a Story  :  IRAF Links  :  Past Polls  :  Calendar  :  Advanced Search  
     iraf.net
FAQ
 Forum FAQForum FAQ   Forum SearchForum Search   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

dealing with spaces (" ") in image names

 
Post new topic   Reply to topic    iraf.net Forum Index -> General IRAF
View previous topic :: View next topic  
Author Message
AndrewS
Active IRAF User


Joined: 10 Oct 2010
Posts: 33
Location: Galway Ireland

PostPosted: Wed Jun 15, 2011 3:49 pm    Post subject: dealing with spaces (" ") in image names Reply with quote

I have a set of .fit files with a space (" ") instead of a hyphen ("-") or underscore ("_") separting the components, eg:

first second1.fit
first second2.fit
first second3.fit
etc.

I want to rename them with a connecting character (such as hyphen), eg:

first-second1.fit
first-second2.fit
first-second3.fit
etc.

so step one is list all the files into a text file, say original.txt and then create a second textfile with the spaces replaced by hyphen, call that altered.txt - this much can be done with translit...finally I want to use imcopy to rename them:

Code:

imcopy @original.txt @altered.txt


however, imcopy does not recognise the space and so I get error message:

Quote:

ERROR: Cannot open image (firstsecond.fit)


ie the space was ignored....

Be grateful for advice on how to deal with this.
Back to top
View user's profile Send private message
fitz
Site Admin


Joined: 30 Sep 2005
Posts: 3257
Location: Tucson

PostPosted: Wed Jun 15, 2011 4:00 pm    Post subject: Reply with quote

Spaces aren't legal in IRAF filenames, even if you quote or escape them in many cases. Simplest thing is to deal with this outside of IRAF entirely, e.g.

Code:
% paste original.txt altered.txt | sed -e "s/^/mv /g" > rename.sh
% sh rename.sh


where I'm assuming the filenames in 'original.txt' have the spaces escaped with a backslash. This will create a 'rename.sh' script using the unix 'mv' command to rename the files.

Note the same issue applies to directory names, e.g. if the path to your data directory is "/home/Andys Computer/data" you may encounter problems.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    iraf.net Forum Index -> General IRAF All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2009 phpBB Group
 Copyright © 2005-2011 iraf.net
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.16 seconds