|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Script to move files in multiple folders
Hello all,
I would appreciate any help to write a script. I have folder A which contains over 30 thousands xml files, I would like create multiple folders and move those files (500 in each folders). Thank you |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Here is a bash script: Code:
#!/bin/bash
c=1; d=1; mkdir -p dir_${d}
for xml_file in *.xml
do
if [ $c -eq 501 ]
then
d=$(( d + 1 )); c=0; mkdir -p dir_${d}
fi
echo mv "$xml_file" dir_${d}/
c=$(( c + 1 ))
doneNote: Remove the highlighted echo if the output looks good. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell Script to delete files within a particular time frame under multiple sub folders | whysolucky | Shell Programming and Scripting | 3 | 08-22-2012 01:17 PM |
| Move folders from Multiple remote Servers to my local computer | idiazza | UNIX for Advanced & Expert Users | 5 | 09-19-2011 08:22 PM |
| Help with auto-detect new files/folders then zip and move script | juzt1s | Shell Programming and Scripting | 1 | 11-24-2010 08:25 AM |
| Shell script to move files to 3 different folders | wretchedmike | Shell Programming and Scripting | 11 | 07-15-2009 12:57 PM |
| moving multiple folders/files in subversion using bash script | ravishan21 | Shell Programming and Scripting | 2 | 11-12-2008 04:35 AM |
|
|