Move files in a list...

Joined
Oct 19, 2009
Messages
17
Reaction score
2
Points
3
Your Mac's Specs
MacBook Pro 13" 2.53GHz 4GB OSX 10.6
Hi

I hope this is the correct forum to ask my question...
I have to work with a bunch of files but those files are named in a...stupid way. Fortunately I'm able to list all files with certain parameters in a list, but what I want to do now is to move only the files which are mentioned in such a list to another directory.

Is there a bash command which can do this? To move only the files mentioned in a list?

cheers
 
Joined
Jan 12, 2009
Messages
1,096
Reaction score
19
Points
38
Location
Prague, Czech Republic
Your Mac's Specs
2,4Ghz 15" unibody
Why not move directly without creating a list using wildcards? Would that be a solution?

e.g.:
mv ./*stupid_name*.txt ./folder
 
OP
Antares
Joined
Oct 19, 2009
Messages
17
Reaction score
2
Points
3
Your Mac's Specs
MacBook Pro 13" 2.53GHz 4GB OSX 10.6
Well, thats the reason why I ask this question in the first place. The files have different parameters which are not reflected in their names...

say you have files named like this:

1.fits
2.fits
3.fits
4.fits
...
456.fits
457.fits

but only a subgroup of them belongs together. Its possible for me to create lists of all files with one particular parameter, but not moving them with wildcards because of the filenames...
 
Joined
Jan 12, 2009
Messages
1,096
Reaction score
19
Points
38
Location
Prague, Czech Republic
Your Mac's Specs
2,4Ghz 15" unibody
...but only a subgroup of them belongs together. Its possible for me to create lists of all files with one particular parameter, but not moving them with wildcards because of the filenames...

How do you create these lists? If it's some sort of "find" or "grep" then you can use wildcards. Are you saying you create these lists manually?

Please give another example of these parameters, I'm thinking no matter how you create that list (if it's with bash) you should be able to use that as the source part for mv.
 
Joined
Jan 12, 2009
Messages
1,096
Reaction score
19
Points
38
Location
Prague, Czech Republic
Your Mac's Specs
2,4Ghz 15" unibody
Ok I will stop tormenting you, there is another option. Look at the following script:
Code:
for i in `cat list`
do
mv `echo $i` <destination>/`echo $i`
done

Keep in mind you need to save that in a file and add execute permissions with chmod +x. I'm not sure how comfy you are with scripting, so let me know if you need additional info as to how to run this.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top