Script to move files in multiple folders | Unix Linux Forums | Shell Programming and Scripting

  Go Back    

Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Script to move files in multiple folders

Shell Programming and Scripting

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 01-19-2013
mmsiddig mmsiddig is offline
Registered User
Join Date: Nov 2012
Last Activity: 18 March 2013, 12:20 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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
Old 01-19-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
Join Date: Jan 2012
Last Activity: 24 February 2015, 2:15 PM EST
Location: Galactic Empire
Posts: 3,401
Thanks: 240
Thanked 1,215 Times in 1,141 Posts
Here is a bash script:


c=1; d=1; mkdir -p dir_${d}

for xml_file in *.xml
        if [ $c -eq 501 ]
                d=$(( d + 1 )); c=0; mkdir -p dir_${d}
        echo mv "$xml_file" dir_${d}/
        c=$(( c + 1 ))

Note: Remove the highlighted echo if the output looks good.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 02:17 PM
Move folders from Multiple remote Servers to my local computer idiazza UNIX for Advanced & Expert Users 5 09-19-2011 09:22 PM
Help with auto-detect new files/folders then zip and move script juzt1s Shell Programming and Scripting 1 11-24-2010 09:25 AM
Shell script to move files to 3 different folders wretchedmike Shell Programming and Scripting 11 07-15-2009 01:57 PM
moving multiple folders/files in subversion using bash script ravishan21 Shell Programming and Scripting 2 11-12-2008 05:35 AM

All times are GMT -4. The time now is 09:53 AM.