Microsoft
Software
Hardware
Network
Question : Bash script to move and rename files based on a file name
I have a bunch of files that I need to move based on a file name and than once moved files need to be renamed:
Example:
group of files
[...]
005512345.txt
0055742394.txt
[...]
to be moved based on its 4th and 5th character (55) to a folder 55 and then renamed to file 12345..742394.txt (remove first four characters). All files are numeric names and all folders are in the same directory level, and folders are already created.
Please help ASAP.
Thank you.
Answer : Bash script to move and rename files based on a file name
try
cd /dir
ls | while read file
do
dir=`echo $file | cut -c3,4`
nfile=`echo $file | cut -c5-`
mv $file /path/to/$dir/$nfile
done
Random Solutions
Microsoft .wdb file to export or save as another Format
Web content filtering devices ACVICE PLEASE!!
MS Access does not connect to MS SQL 2008 through ODBC
TCP/IP settings in sysprep.inf
cannot access EXE files in normal mode. getting device / path / file not found error.
php and mysql search
MAke auto-increment column NOT primary key??
ASP wont work in IIS 7 vista
How i get Java script poopup whcih display YES/NO instead of Ok/Cancel Button?
Exchange 2003 - Some SMTP messages not leaving the queue