View Full Version : Unix command line question
goodfear
3rd May 2005, 17:58
i have a unix command line question
i have a huge file sequence currently all in one directory, 58,000 frames to be exact. i need to break this up into sub dirs with 5000 frames per.
can someone help me out with a little unix command line help to do this?
my file are named like this filename_rsz_000001.tga
my sub dirs are set up like this
00000_05000, 05001_10000 and so on....
thanks
mdoane
3rd May 2005, 18:09
The fm command might help you out. Once typed in a gooey window will open and show everything in that directory. Just cd to the dir and once there type fm and enter. Below is a link to the man pages @ sgi.com
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?cmd=getdoc&coll=0650&db=man&fname=1%20fm
md
chrise
5th May 2005, 18:35
i have a unix command line question
i have a huge file sequence currently all in one directory, 58,000 frames to be exact. i need to break this up into sub dirs with 5000 frames per.
can someone help me out with a little unix command line help to do this?
my file are named like this filename_rsz_000001.tga
my sub dirs are set up like this
00000_05000, 05001_10000 and so on....
thanks
I often use a perl script to generate a file full of commands to do this kind of thing. This allows you to read through what is going to happen before you actually do it - which can save you if you are trying to do things like this quickly.
1. Make a perl script containing something like this (using nedit) :
#!/usr/bin/perl
$X=1;
$Y=1;
while ($X<5000) {
$OUTSTRING=sprintf( "mv filename_rsz_%06d.tga 000000_050000/filename_rsz_%06d.tga" , $X , $Y);
print "$OUTSTRING \n";
$X=$X+1;
$Y=$Y+1;
}
I hope that it is reasonably clear what is going on in the perl script. The
sprintf line is required to get the padding in your frame numbers. In
the above example I have 0 padded the names with 6 digits as in your question.
2. Assume we called the perl file above makeit.pl. Make the perl file executable with
chmod 755 makeit.pl
3. Run the perl file like this
./makeit.pl > doit.sh
4. You will now have file called doit.sh with 5000 mv commands in it.
You can check through this file (using less or nedit or something) and
then, if everything looks good, you can go ahead and actually move the files.
5. sh doit.sh
6. A quick edit to the perl script to move the next 5000 and you can
generate another doit.sh and move the next 5000 files.
Thats the basic idea, it's a very flexible (and safe) method of renaming things. Saves a lot of grief with shell expansions only going to 1024 and
other system limitations like that.
Hope that it helps.
Chris
[/code][/quote]
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.