Joined: 10 Oct 2010 Posts: 33 Location: Galway Ireland
Posted: Wed Jun 15, 2011 3:49 pm Post subject: dealing with spaces (" ") in image names
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:
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.
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