Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Move files in a list... (http://www.mac-forums.com/forums/os-x-development-darwin/210506-move-files-list.html)

Antares 08-05-2010 06:10 AM

Move files in a list...
 
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

scathe 08-05-2010 08:56 AM

Why not move directly without creating a list using wildcards? Would that be a solution?

e.g.:
mv ./*stupid_name*.txt ./folder

Antares 08-05-2010 09:04 AM

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...

scathe 08-05-2010 09:10 AM

Quote:

Originally Posted by Antares (Post 1093813)
...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.

scathe 08-05-2010 09:27 AM

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.


All times are GMT -4. The time now is 11:19 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.