Create folder by script & move files in it | Unix Linux Forums | Linux

  Go Back    

Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

Create folder by script & move files in it


Closed Thread    
Thread Tools Search this Thread Display Modes
Old 10-28-2011
paragnehete paragnehete is offline
Registered User
Join Date: Apr 2011
Last Activity: 19 May 2014, 11:31 PM EDT
Posts: 22
Thanks: 2
Thanked 0 Times in 0 Posts
Create folder by script & move files in it

Hi Team,

I have over 1 lakh pdf files.

I want to create folders like Disk-1, Disk-2 ..... & want to move 3000 pdfs per folder. Can i do it by script? Please help me.

Thanks & Regards
Parag Nehete
Sponsored Links
Old 10-28-2011
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
Join Date: Jan 2009
Last Activity: 6 February 2014, 9:06 AM EST
Location: Bangalore,INDIA
Posts: 507
Thanks: 4
Thanked 27 Times in 27 Posts
Yes it can be done . First try out yourself . The logic is in script is first try to creat the Folder "DISK1" here the number can be a variablke and after transfering the 3000 file increase the variable by 1.

PHP Code:
# start with a loop to check if the files are still remaining to be transfered 
mkdir DISK$dn
while [ $i -le 3000 ];do 
# here your logic to move the files to the DISK folder
i=$(( $i ))
Sponsored Links
Old 10-28-2011
jayan_jay's Avatar
jayan_jay jayan_jay is offline Forum Advisor  
Forum Advisor
Join Date: Jul 2008
Last Activity: 21 April 2014, 7:19 AM EDT
Posts: 833
Thanks: 9
Thanked 185 Times in 176 Posts

find $pdf_path -type f -name "*.pdf" -print > filecon
split -3000 filecon
for i in x*
        mkdir $pdf_path/Disk-$disk
        nawk -F/ 'BEGIN{OFS="/"} {print "mv "$0; $NF=""; print}' $i | paste - - | nawk -v diskno="Disk-$disk" '{print $0diskno}' | sh
        disk=`expr $disk + 1`

Old 10-29-2011
mark54g mark54g is offline Forum Advisor  
Registered User
Join Date: May 2008
Last Activity: 26 July 2013, 11:43 AM EDT
Location: Northeastern United States
Posts: 918
Thanks: 1
Thanked 61 Times in 58 Posts
And just what is a lakh?
Sponsored Links
Old 10-29-2011
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Advisor  
Forum Advisor
Join Date: Feb 2005
Last Activity: 20 December 2014, 9:11 PM EST
Location: Foxborough, MA
Posts: 7,679
Thanks: 156
Thanked 591 Times in 555 Posts
Originally Posted by mark54g View Post
And just what is a lakh?
And the winner is.... Lakh.
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
Move only files to a folder brnl_basu Shell Programming and Scripting 4 06-23-2011 05:40 AM
Script to move files with similar names to folder glev2005 Shell Programming and Scripting 7 04-01-2011 10:42 AM
Move files & folder structure SOCLA_CELT Shell Programming and Scripting 3 08-26-2010 07:47 PM
move files to some folder learnbash Shell Programming and Scripting 2 07-20-2010 05:37 AM
move files from folder thats are not empty Steven UNIX for Dummies Questions & Answers 8 11-21-2001 10:05 AM

All times are GMT -4. The time now is 10:34 PM.