LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 06-16-2017, 04:28 PM   #16
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 289

Rep: Reputation: 89

The older threads at the bottom of the page provide plenty or examples of how to do this. If you did want to use mv you would have to do it in a loop.

The thread by samnjugu has the following example to change all extensions from .wma.ogg to .ogg.

Code:
for file in *.wma.ogg
do
 mv "${file}" "${file/.wma.ogg/.ogg}"
done
In your case this works out to something like

Code:
for file in *.x86_64-170614.0.0.iso-kiwi_src.tar.gz
do
 mv "${file}" "${file/.x86_64-170614.0.0.iso-kiwi_src.tar.gz/.170614.x64.kiwi.tgz}"
done
jmgibson1981 you should have looked at the older threads listed at the bottom before posting.
 
1 members found this post helpful.
Old 06-24-2017, 06:02 AM   #17
hd_scania
Member
 
Registered: Apr 2017
Location: Kowloon, Hong Kong, Great Britain
Distribution: HBSD, Parabola, Void, Gentoo, SliTaz, PCLOS, Devuan, PureOS, Trisquel, Hyperbola, Trident, GhostBSD
Posts: 139

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
Question

Code:
hdscania@buster /data/vm $ cd /data/lib/onDLine
hdscania@buster /data/lib/onDLine $ ls -la
total 21664
drwxr-xr-x.  2 hdscania hdscania    4096 Jun 24 17:56 .
drwxr-xr-x. 12 hdscania hdscania    4096 Jun 18 18:44 ..
-rw-r--r--   1 hdscania hdscania 4356474 Jun 24 17:56 CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-rw-r--.  1 hdscania hdscania  618466 May 28 09:16 endlesssummer.tdesktop-theme
-rw-r--r--.  1 hdscania hdscania   65071 Dec 18  2016 .facebook_1480784994461.jpg
-rw-r--r--   1 hdscania hdscania 2198015 Jun 24 17:56 FreeXP.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-rw-r--.  1 hdscania hdscania   10752 May 10 18:16 Investigative_Artistic.xls
-rw-r--r--   1 hdscania hdscania 1623793 Jun 24 17:55 LittleXC.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-r--r--   1 hdscania hdscania 3640674 Jun 24 17:56 Nelson.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-r--r--   1 hdscania hdscania 2188596 Jun 24 17:56 OS18.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-r--r--   1 hdscania hdscania 4356432 Jun 24 17:56 QtBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-r--r--   1 hdscania hdscania 2938977 Jun 24 17:55 XfBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
-rw-rw-r--.  1 hdscania hdscania  131072 May 28 09:17 XS2.tdesktop-theme
hdscania@buster /data/lib/onDLine $ mv "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
mv: cannot stat '': No such file or directory
hdscania@buster /data/lib/onDLine $ mv ./ "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
mv: target '' is not a directory
hdscania@buster /data/lib/onDLine $ mv "${./*}" "${./*/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
bash: ${./*}: bad substitution
hdscania@buster /data/lib/onDLine $ mv "${./}" "${.//.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
bash: ${./}: bad substitution
hdscania@buster /data/lib/onDLine $ mv "${*.gz}" "${*.gz/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
bash: ${*.gz}: bad substitution
hdscania@buster /data/lib/onDLine $ mv "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
mv: cannot stat '': No such file or directory
hdscania@buster /data/lib/onDLine $ mv "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}"
mv: cannot stat '': No such file or directory
hdscania@buster /data/lib/onDLine $ mv "${*}" "${*/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}"
mv: cannot stat '': No such file or directory
hdscania@buster /data/lib/onDLine $
I have now left Fedora yet this also DSNT seem to work on Linux Mint, so what mods are needed to be fit under Linux Mint (and any Debian derivatives)?
Quote:
Originally Posted by tofino_surfer View Post
The older threads at the bottom of the page provide plenty or examples of how to do this. If you did want to use mv you would have to do it in a loop.

The thread by samnjugu has the following example to change all extensions from .wma.ogg to .ogg.

Code:
for file in *.wma.ogg
do
 mv "${file}" "${file/.wma.ogg/.ogg}"
done
In your case this works out to something like

Code:
for file in *.x86_64-170614.0.0.iso-kiwi_src.tar.gz
do
 mv "${file}" "${file/.x86_64-170614.0.0.iso-kiwi_src.tar.gz/.170614.x64.kiwi.tgz}"
done
jmgibson1981 you should have looked at the older threads listed at the bottom before posting.
 
Old 06-24-2017, 09:26 AM   #18
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,599

Rep: Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494
use set -xv to check what's happening and post its output.
fedora and mint will do this job exactly the same way.
 
Old 06-24-2017, 08:04 PM   #19
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 289

Rep: Reputation: 89
Quote:
hdscania@buster /data/lib/onDLine $ mv "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
mv: cannot stat '': No such file or directory
What the hell are you doing! This needs to be done inside a loop as file is a variable. When executed by itself file is not set to anything which is why an empty string cannot be found. Do you not understand this ? This has nothing to do with what distribution you are using. What you are trying will fail on any distribution as it is incorrect and doesn't make any sense. All of the other commands you are attempting are similarly worthless.

Code:
for file in *.x86_64-170614.0.0.iso-kiwi_src.tar.gz
do
 mv "${file}" "${file/.x86_64-170614.0.0.iso-kiwi_src.tar.gz/.170614.x64.kiwi.tgz}"
done
The shell builds a list of all files with the extension .x86_64-170614.0.0.iso-kiwi_src.tar.gz and iterates over this list. Each time through the loop a different filename in this list is assigned to the variable file. The mv command won't work outside of this loop unless the variable file is set manually each time. As you have many files a loop is much easier.

I gave you a solution based on a post from many years ago. You simply need to use the whole loop.

Last edited by tofino_surfer; 06-24-2017 at 08:14 PM.
 
1 members found this post helpful.
Old 06-24-2017, 08:38 PM   #20
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 289

Rep: Reputation: 89
If you wanted to test the command outside of a loop you would have to set the variable file manually in a shell. If you wanted to test renaming a single file do the following. As the variable file is set to an existing filename the mv command will now work.

Code:
$file=CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
$ echo $file
CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
$ mv "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
‘CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz’ -> ‘CinnaBang.170624.x64.kiwi.tgz’
To rename all of your files use the loop I gave.

Last edited by tofino_surfer; 06-24-2017 at 08:47 PM. Reason: simplified post
 
1 members found this post helpful.
Old 06-25-2017, 03:33 AM   #21
hd_scania
Member
 
Registered: Apr 2017
Location: Kowloon, Hong Kong, Great Britain
Distribution: HBSD, Parabola, Void, Gentoo, SliTaz, PCLOS, Devuan, PureOS, Trisquel, Hyperbola, Trident, GhostBSD
Posts: 139

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by tofino_surfer View Post
If you wanted to test the command outside of a loop you would have to set the variable file manually in a shell. If you wanted to test renaming a single file do the following. As the variable file is set to an existing filename the mv command will now work.
Code:
$file=CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
$ echo $file
CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz
$ mv "${file}" "${file/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -v
‘CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz’ -> ‘CinnaBang.170624.x64.kiwi.tgz’
To rename all of your files use the loop I gave.
I think I have now understood what you mean, what I FIRSTLY need before what I ULTIMATELY need to do are just:
Code:
$ env && printenv && set
$ setenv $SRC=CinnaBang.x86_64-170624.0.0.iso-kiwi_src.tar.gz && echo $SRC
$ mv "${SRC}" "${SRC/.x86_64-170624.0.0.iso-kiwi_src.tar.gz/.170624.x64.kiwi.tgz}" -xv
Are these COMPLETE commands correct thanks?
 
Old 06-26-2017, 03:20 AM   #22
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,599

Rep: Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494Reputation: 3494
what kind of shell is it? (bash/sh/tcsh/whatever??)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] Batch rename directories? junglepunk Linux - Newbie 3 03-13-2014 06:34 AM
Batch rename files samnjugu Linux - Desktop 7 06-02-2009 11:06 AM
Batch rename troubles djeikyb Linux - General 4 07-04-2007 03:38 PM
Batch Rename shelfitz Linux - Newbie 19 10-12-2006 11:23 PM
Batch rename question hellblade Linux - Software 4 05-03-2004 04:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:49 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration