Script to create folders and move files.
Hi all. I need pointers on either where to find help on, or help with a script to create numbered folders. I want to create folders according to the standard; "dd-mm-yyyy-xx" where "dd" is day, "mm" is month, "yyyy" is year and xx is a running number. If one folder "-01" exists the script checks for "-02" etc. Its to transfer all images from a flashcard Here's what i want it to do (Automount of a USB disk. ( /mnt/sda(x) ) check where it is mounted ( sda(x) ) mkdir /mnt/sda(x)/backup/<dated foldername> cp /mnt/sda1/drive/files/* /mnt/backup/<dated foldername>/* rm /mnt/sda1/drive/files/* It really doesnt matter if its in Bash, Perl or whatever. Anything goes as long as it works. -- /Rikard --------------------------------------------------------------- Rikard Johnels email : rikjoh@norweb.se Web : http://www.rikjoh.com/users/rikjoh Mob : +46 735 05 51 01 PGP : 0x461CEE56 ---------------------------------------------------------------
Rikard, On Wednesday 02 February 2005 16:06, Rikard Johnels wrote:
Hi all.
I need pointers on either where to find help on, or help with a script to create numbered folders. I want to create folders according to the standard; "dd-mm-yyyy-xx" where "dd" is day, "mm" is month, "yyyy" is year and xx is a running number. If one folder "-01" exists the script checks for "-02" etc.
Its to transfer all images from a flashcard
Here's what i want it to do
(Automount of a USB disk. ( /mnt/sda(x) )
check where it is mounted ( sda(x) ) mkdir /mnt/sda(x)/backup/<dated foldername> cp /mnt/sda1/drive/files/* /mnt/backup/<dated foldername>/* rm /mnt/sda1/drive/files/*
It really doesnt matter if its in Bash, Perl or whatever. Anything goes as long as it works.
Check out the output formatting options of the date command. E.g., % date +"Today: %Y-%m-%d" Today: 2005-02-02 % BASH has rudimentary integer variable support: % count=0 % echo $count 0 % let 'count++' % echo $count 1 % With a for loop: % count=0 % for arg in 1 two III; do
echo "arg=$arg at $(date +"%Y-%m-%d-%H-%M-%S-%N.$count")" let count++ done arg=1 at 2005-02-02-16-29-175966000.0 arg=two at 2005-02-02-16-29-179280000.1 arg=III at 2005-02-02-16-29-182597000.2 %
/Rikard
Randall Schulz
On Wednesday 02 February 2005 16:06, Rikard Johnels wrote:
I want to create folders according to the standard; "dd-mm-yyyy-xx" where "dd" is day, "mm" is month, "yyyy" is year and xx is a running number. If one folder "-01" exists the script checks for "-02" etc.
Hi Rikard,
I'm using a bash function to create backups of files with a target naming
convention similar to what you are looking for. You might be able to build
your own function based on it. Code is attached.
Michael
participants (3)
-
Michael Siefritz
-
Randall R Schulz
-
Rikard Johnels