I have many pdf files with similar naming conventions as this one: AC41_AC85_86_AC128_129_MC171_173_SF_207_FMV.pdf. It is a pdf file containing evaluations for these locations: AC41, AC85, AC86, AC128, AC129, MC171, and MC173.
I want to create a directory for every location and put the associated pdf in that directory.
The final product I want is a directory named AC41 and to put the file AC41_AC85_86_AC128_129_MC171_173_SF_207_FMV.pdf into the directory. Next, a directory named AC85 and put the file into it. Also, continue to cycle through this pdf and all pdfs in the folder.
I have a script:
This only creates one directory per file. What am I missing?
Last edited by pludi; 04-02-2010 at 02:16 AM..
Reason: code tags, please...
Your variable subsitution removes the string "_FMV.pdf" from the end of $f and puts that into $d. However, the value of $d is then AC41_AC85_86_AC128_129_MC171_173_SF_207.
I'm surmising this is the name of the one directory that is getting created, and it moves the pdf file there, based upon your script.
You'll need to break out the values of $d in some way so that you can then create the appropriate individual directories AC41, AC85, etc. and place the file in each of them.
One caveat I see is that some of the numbers in the file name don't have the matching letter prefix to your location list. Like AC86, there is just an 86, so if you don't want a directory named simply '86' you'll need to handle this condition. Also, you don't list 'SF' or the '207' as locations and those values are still in $d after your substitution.
Assuming you've planned out your location anomalies, you can break out $d like this:
I want to create a new system of directory structure for example
mkdir -p ./iv.sac/resu/hhz.d
However, I think that `mkdir -p` overwrites the directories. I want to avoid that
and am doing something as follows in my bash script
echo -e "\nCreating directories:" ... (6 Replies)
Hi all. I'm hitting a problem creating a tar archive in one directory from files located in a different directory. It fails when I replace the absolute paths with variables in the script but works if I just run tar on the cmdln. E.g.
#!/bin/ksh
BASE=$PWD
STAGE=$BASE/stage
LOG=$BASE/log... (4 Replies)
how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex.
so
mydemo--2015-03-23-1500.tar.gz
> database
-... (5 Replies)
i'm trying to write a script that has 2 variables, and uses the 1st variable as a number and the 2nd a name to create directories. so if you typed in ./myscript 5 week, it would create 5 directories named week1 - week5. whenever i run this, i get an error message saying week5 already exists, so i... (3 Replies)
Hi,
I am looking for the syntax to provide a timestamped log_file in expect.
Basically I want the equivalent of:
/outputs/`date +%d%m%y`/session`date +%H%M`
But scripted in expect so it can be handed over to the logfile function.
I have tried playing around with the timestamp... (1 Reply)
I have an interesting requirement. I have declaried an array like :-
arr=`find . ! -name "." | xargs -I {} echo {} | cut -c 2-${#}`
Then i will try to access the array elements like :-
i=0
for i in ${arr}; do
Here comes the confusions, the array elements are basically dir and files stored... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Ok i need to create a directory within another directory in one command. I'm already in a directory to. I need to... (6 Replies)
Hi,
Can someone help me with creating a bash shell script.
I need to create a script that gets a positive number n as an argument.
The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
I have two login accounts 'fup04a' and 'fup04c' on the same unix box
after log in using 'fup04a' and if I try creating a directory 'new'
drwxrwxr-x 2 fup04a fup04a 4096 Nov 14 14:06 new
but if i try the same with fup04c
drw-rw-r-x 2 fup04c fup04c 4096 Nov 14... (3 Replies)
how do i create directories using command in my unix system, i could do with knowing how to do it with absolute pathnames and relative pathnames please (3 Replies)