LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-31-2013, 09:14 PM   #1
Moksha
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Rep: Reputation: Disabled
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.
 
Old 12-31-2013, 10:32 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I am not sure I follow 100% but are you looking for something like:
Code:
mkdir "${PWD}jpg"
 
Old 12-31-2013, 11:28 PM   #3
Moksha
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
that makes testjpg a sister directory to test, not a child of test which is what I want, but many thanks
 
Old 01-01-2014, 12:16 AM   #4
ericson007
Member
 
Registered: Sep 2004
Location: Japan
Distribution: CentOS 7.1
Posts: 735

Rep: Reputation: 154Reputation: 154
Nef is propriety used on nikon slrs, how will you get the conversion done? I don't think a simple rename will work.
 
Old 01-01-2014, 12:53 AM   #5
Moksha
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ericson007 View Post
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
 
Old 01-01-2014, 02:52 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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
 
Old 01-01-2014, 04:26 AM   #7
Moksha
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
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$
 
Old 01-01-2014, 04:42 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Sorry .. I forgot about the full path being there

Try:
Code:
mkdir "${PWD##*/}jpg"
 
Old 01-01-2014, 04:49 AM   #9
Moksha
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
Sorry .. I forgot about the full path being there

Try:
Code:
mkdir "${PWD##*/}jpg"
thank you that worked what does the ##*/ do
 
Old 01-01-2014, 05:23 AM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Search on this page for ${var##Pattern}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ksh scripting: dynamic variable naming bracken84 Programming 7 02-20-2012 03:20 AM
Question on variable naming and assignment... ${manintheyellowhat} Linux - Newbie 6 07-26-2010 07:41 PM
Bash Variable Naming Question? Speedy2k Linux - Newbie 7 06-01-2010 08:23 AM
Bash Shell Scripting Dynamic Variable naming question ZuG Programming 2 02-07-2007 02:39 PM
variable naming conventions patpawlowski Programming 6 02-25-2004 01:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration