LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   mkdir naming variable (https://www.linuxquestions.org/questions/programming-9/mkdir-naming-variable-4175489754/)

Moksha 12-31-2013 09:14 PM

mkdir naming variable
 
I am trying to make a batch command set that will convert files from .NEF to .jpg and place them in a directory with the same name as the parent + jpg attached to the end within the parent directory.

Code:

mkdir $(name of parent directory + jpg) # ie /test would now contain /testjpg as a sub directory#; ufraw-batch --out-type=jpg *.NEF ; mv *.jpg testjpg
Running the command set in a directory called photos with files 001.NEF, 002.NEF would create directory photosjpg within photos containing the files 001.jpg and 002.jpg. The original .NEF files would remain in photos.

grail 12-31-2013 10:32 PM

I am not sure I follow 100% but are you looking for something like:
Code:

mkdir "${PWD}jpg"

Moksha 12-31-2013 11:28 PM

that makes testjpg a sister directory to test, not a child of test which is what I want, but many thanks

ericson007 01-01-2014 12:16 AM

Nef is propriety used on nikon slrs, how will you get the conversion done? I don't think a simple rename will work.

Moksha 01-01-2014 12:53 AM

Quote:

Originally Posted by ericson007 (Post 5089970)
Nef is propriety used on nikon slrs, how will you get the conversion done? I don't think a simple rename will work.

it is not a simple rename and the part you are talking about works. I am interested in something along the lines of
Code:

home$:mkdir "${PWD}jpg"
nikon is sorted. thanks

grail 01-01-2014 02:52 AM

Quote:

that makes testjpg a sister directory to test, not a child of test which is what I want, but many thanks
Actually that is incorrect. $PWD stores the name of the directory you are in, hence issuing the command would result in a directory being created as a child

Moksha 01-01-2014 04:26 AM

Quote:

Originally Posted by grail (Post 5090004)
Actually that is incorrect. $PWD stores the name of the directory you are in, hence issuing the command would result in a directory being created as a child

I know what you are saying and I agree with you but I am passing on what I am getting. I am issuing the command from within the directory /home/test and it is creating /home/testjpg.

Code:

Study@Study:~$ ls
Accounts        Library                test
Calibre Library  Mail                    The Blues Brothers (1980) [1080p]
Desktop          Music                  The Usual Suspects
Documents        MUSIX_GNU+Linux_3.0rc1  vids
Downloads        MyMachines              VirtualBox VMs
Dropbox          Pictures                workspace
Holidays        Scrabble               
Jobs            Shared
kde3-backup      sketchbook
Study@Study:~$ cd test
Study@Study:~/test$ mkdir "${PWD}jpg"
Study@Study:~/test$ ls
tect.txt
Study@Study:~/test$ ls ..
Accounts        Library                test
Calibre Library  Mail                    testjpg
Desktop          Music                  The Blues Brothers (1980) [1080p]
Documents        MUSIX_GNU+Linux_3.0rc1  The Usual Suspects
Downloads        MyMachines              vids
Dropbox          Pictures                VirtualBox VMs
Holidays        Scrabble                workspace
Jobs            Shared                 
kde3-backup      sketchbook
Study@Study:~/test$


grail 01-01-2014 04:42 AM

Sorry .. I forgot about the full path being there :(

Try:
Code:

mkdir "${PWD##*/}jpg"

Moksha 01-01-2014 04:49 AM

Quote:

Originally Posted by grail (Post 5090025)
Sorry .. I forgot about the full path being there :(

Try:
Code:

mkdir "${PWD##*/}jpg"

thank you that worked what does the ##*/ do

grail 01-01-2014 05:23 AM

Search on this page for ${var##Pattern}


All times are GMT -5. The time now is 02:24 AM.