Batch processing files through an interactive script
I am newish to the site and to unix.
I have a functioning interactive script running on Mac that sorts and processes files located in an unsorted folder on my desktop.
As it currently stands, the user types jpg into the command line, the script executes and iterates through the unsorted folder where it takes files of type jpg and make a new directory on the desktop and moves them.
Its working terrific, but I want to develop the script further so that I can batch process without having to type single terminal commands one at a time.
i.e. I can type a series of arguments into the terminal jpg gif docx and the script will run and make new desktop directories for jpg gif docx and move all of these file types into such.
The only caveat is, The remaining miscellaneous files in the unsorted folder (.wav png and a whole litany of other extensions) need to have a miscellaneous folder created in the desktop and moved into such as soon as I run the batch.
What is the leanest way of achieving such.
Last edited by Braveheart; 11-26-2016 at 11:51 AM..
That seems to be a bash script, so be careful when running it with another shell.
How about reading in your space separated list of arguments and then using a for loop to loop through all of them? After the loop, run a similar logic again for the rest of the (unaddressed) extensions.
appreciate the prompt response, how do you mean by reading in your separated list of arguments. my apologies if the question is elementary ( I am first year software student)
Try, then,
and report back on any difficulties or problems. It needs a recent bash, and the while loop is an alternative to a for construct. The echoes are a safety measure; remove them if happy with the output.
Rudi, I managed to get it 3 quarters working which is a fantastic start. The folders are created for each of the three files stipulated in the terminal (jpg gif docx) and upon execution of the script, the new new folders are made and the files moved into their. Only thing I need to figure out is the miscellaneous folder is not created and the resulting extensions bumped into it.
Last edited by Braveheart; 11-26-2016 at 01:04 PM..
Hello,
I have to encrypt data using a script in batch mode without being prompted. I can successfully encrypt data but it prompts me to enter (y/N) as shown below. I tried batch flags without no success. I need to automate this without any prompts. Appreciate your inputs.
Thanks,
C.
$... (2 Replies)
Hello,
I have a UNIX script to sftp batch processing. Here is my sftp command.
ftp -b toopc userid@sftp.hostname.com
In the file toopc I have the following commands:
mget *.csv
bye
This brings in all files with an extension of .csv
However, I need to only bring in files that
... (6 Replies)
I am new to Shell Scripting and need some help.
The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below.
I am on a solaris server btw.
Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose.
... (2 Replies)
How to batch-processing numerous shell scripts?
how to record the result of all the scripts as a report? then, I can analysis the process result.
I want to process numerous shell scripts in my working directory:
the directory name is consistent with shell scripts name, that is to say,... (2 Replies)
hi i have a folder full of files. some of the names are quite off because the dimensions were the same and i had to put a 'b' after the initial number so that it didnt overwrite. what i want is a script in unix to overwrite the filwe name leaving some of the title intact, e.g. below are some... (3 Replies)
Hi All,
I want to process consecutive jobs in a sequence but when I execute 1 job ,the control does not return to the command prompt to continue with the next job.
Can anyone help me here?
Thanks (3 Replies)
Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines.
It then prompts for deletion of the file.
If user supplies arguments with the script , then it works on those files... (8 Replies)
Hello Everyone!!!
I need some help with a shellscript to batch process a folder of files with the imagemagick convert -append/+append command. The folder contains some hundred or thousand of small images in .png format which I would like to join together in order of their filenames. The... (3 Replies)
Hi all,
We are running a batch job using Unix script. This batch job is running daily to get data from a Mainframe database and to load our tables. We are using an interactive ID for the batch job. If we removed that interactive ID, the batch job fails. What's my question is.. Is the... (1 Reply)