| | |
copying multiple files with user input
![]() |
•
•
Join Date: Nov 2008
Posts: 9
Reputation:
Solved Threads: 0
I'm currently trying to write a shell script at work that would loop and allow me to enter the date, and the ad number of a PDF file, that would then copy that ad into a designated file and I can't get it to run correctly
heres the code:
right now I need to drag and drop multiple files from a few folders, into one folder, I would like to be able to have it go along the lines of...
Enter date for the ad:
22
Enter number for the ad:
107548
then i would like it to copy ad number 107548*pdf from the 22nd folder, into the hotfolder.
thanks in advance,
-Wm.
heres the code:
Shell Scripting Syntax (Toggle Plain Text)
#! /bin/bash year=`date +%Y` month=`date +%m` monthname=`date +%B` day=`date +%d` hotfolder=`expr $day + 2` open "/Volumes/ _Issues/$year/$month $monthname/$hotfolder/" echo "Enter the DATE of the PDF you wish to Copy"; while read inputline do copydate="$inputline" echo "you entered $copydate"; if [ "$copydate" -ge 1 ] then echo "You entered $copydate" fi while read inputline2 do copynum=$inputline2; done
right now I need to drag and drop multiple files from a few folders, into one folder, I would like to be able to have it go along the lines of...
Enter date for the ad:
22
Enter number for the ad:
107548
then i would like it to copy ad number 107548*pdf from the 22nd folder, into the hotfolder.
thanks in advance,
-Wm.
•
•
Join Date: Feb 2006
Posts: 399
Reputation:
Solved Threads: 14
Hi,
You have some spaces which may be causing you some problems. One here:
should be
and also might need to be??
You have some spaces which may be causing you some problems. One here:
Shell Scripting Syntax (Toggle Plain Text)
#! /bin/bash
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash
Shell Scripting Syntax (Toggle Plain Text)
open "/Volumes/ _Issues/$year/$month $monthname/$hotfolder/"
Shell Scripting Syntax (Toggle Plain Text)
open "/Volumes/_Issues/$year/$month $monthname/$hotfolder/"
If my post helped add to my rep!
•
•
Join Date: Feb 2006
Posts: 399
Reputation:
Solved Threads: 14
Also instead of this: Why dont you just use
Shell Scripting Syntax (Toggle Plain Text)
while read inputline do copydate="$inputline" echo "you entered $copydate";
Shell Scripting Syntax (Toggle Plain Text)
while read coypdate do echo "you entered $copydate";
If my post helped add to my rep!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Hey there,
Does the line:
open "/Volumes/ _Issues/$year/$month $monthname/$hotfolder/"
not give you an error for "open"?
Just curious. My bash's do.
Some of the logic of the scripts function doesn't seem to be completed either, like the final move. Is this just part of the code? Or, possibly, a little bit of pseudo code mixed in with regular?
Best wishes,
Mike
Does the line:
open "/Volumes/ _Issues/$year/$month $monthname/$hotfolder/"
not give you an error for "open"?
Just curious. My bash's do.
Some of the logic of the scripts function doesn't seem to be completed either, like the final move. Is this just part of the code? Or, possibly, a little bit of pseudo code mixed in with regular?
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Nov 2008
Posts: 9
Reputation:
Solved Threads: 0
I'm running os x 10.4.8, and my script seems to run with/without the whitespace in the first line, but i removed it either way...
I just removed both while's and do's and placed it in root and made it recursive...and everything seems to work fine now, thanks everyone.
I just removed both while's and do's and placed it in root and made it recursive...and everything seems to work fine now, thanks everyone.
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash year=`date +%Y` month=`date +%m` monthname=`date +%B` day=`date +%d` hotfolder=`expr $day + 2` echo "Enter the DATE of the PDF you wish to Copy"; read inputline copydate="$inputline" echo "you entered $copydate"; echo "Enter the NUMBER of the PDF you wish to copy." read inputline2 copynum=$inputline2; cp "/Volumes/ _Issues/$year/$month $monthname/$copydate/$copynum"* "/Volumes/ _Issues/$year/$month $monthname/$hotfolder/" echo "Copying ad number # $copynum from $copydate to $hotfolder..." echo "Done." exec ~/Desktop/test.sh exit
![]() |
Similar Threads
- Dual-Boot (Multiboot), 9x-2000, 9x-XP (Windows tips 'n' tweaks)
- Cannot find server or DNS Error - please help! (Viruses, Spyware and other Nasties)
- Save WinXP (Geeks' Lounge)
- "Forbidden / You don't have permission to access / on this server." error (Linux Servers and Apache)
Other Threads in the Shell Scripting Forum
- Previous Thread: Script to prompt Linux user for hostname and unique NFS share
- Next Thread: grep command help
| Thread Tools | Search this Thread |






