Sponsored Content
Top Forums Shell Programming and Scripting How to rename multiple file names? Post 302943226 by sea on Wednesday 6th of May 2015 11:33:54 AM
Old 05-06-2015
What i do, looks like:
(might be a little overkill for such a simple substitution, but for certain sed commands, this preview is just 'required' (feels alot more saver)!
(as in, i would had deleted (renamed to empty) quite a few files already)
Code:
:) vid $ cmd=tui-echo
+ vid $ for f in sc* ;do $cmd "$f" "${f/screen/Desktop}"; done
# | screen-.mkv                                                                                     Desktop-.mkv | #
# | screen-out.0.mkv                                                                           Desktop-out.0.mkv | #
# | screen-out.10.mkv                                                                         Desktop-out.10.mkv | #
# | screen-out.11.mkv                                                                         Desktop-out.11.mkv | #
# | screen-out.11.webm                                                                       Desktop-out.11.webm | #
# | screen-out.1.mkv                                                                           Desktop-out.1.mkv | #
# | screen-out.2.mkv                                                                           Desktop-out.2.mkv | #
# | screen-out.3.mkv                                                                           Desktop-out.3.mkv | #
# | screen-out.4.mkv                                                                           Desktop-out.4.mkv | #
# | screen-out.5.mkv                                                                           Desktop-out.5.mkv | #
# | screen-out.6.mkv                                                                           Desktop-out.6.mkv | #
# | screen-out.7.mkv                                                                           Desktop-out.7.mkv | #
# | screen-out.8.mkv                                                                           Desktop-out.8.mkv | #
# | screen-out.9.mkv                                                                           Desktop-out.9.mkv | #
# | screen-out.mkv                                                                               Desktop-out.mkv | #
+ vid $ cmd=mv
+ vid $ for f in sc* ;do $cmd "$f" "${f/screen/Desktop}"; done
✔ vid $ ll D*{mkv,webm}
-rw-rw-r--. 1 sea sea 1.8M 28. Mär 23:44 Desktop-.mkv
-rw-rw-r--. 1 sea sea 593M  7. Mär 23:17 Desktop-out.0.mkv
-rw-rw-r--. 1 sea sea 267K  4. Mai 10:05 Desktop-out.10.mkv
-rw-rw-r--. 1 sea sea  15M  4. Mai 10:10 Desktop-out.11.mkv
-rw-rw-r--. 1 sea sea  13M  4. Mai 11:15 Desktop-out.11.webm
-rw-rw-r--. 1 sea sea 318K 27. Mär 16:39 Desktop-out.1.mkv
-rw-rw-r--. 1 sea sea 1.1M 28. Mär 08:04 Desktop-out.2.mkv
-rw-rw-r--. 1 sea sea 2.5M 28. Mär 12:29 Desktop-out.3.mkv
-rw-rw-r--. 1 sea sea 1.5M 28. Mär 12:35 Desktop-out.4.mkv
-rw-rw-r--. 1 sea sea 805K 28. Mär 17:31 Desktop-out.5.mkv
-rw-rw-r--. 1 sea sea 789K 28. Mär 17:42 Desktop-out.6.mkv
-rw-rw-r--. 1 sea sea  73M 30. Mär 11:13 Desktop-out.7.mkv
-rw-rw-r--. 1 sea sea  98M  4. Apr 11:23 Desktop-out.8.mkv
-rw-rw-r--. 1 sea sea  19M 30. Mär 12:26 Desktop-out.9.mkv
-rw-rw-r--. 1 sea sea  70M 27. Mär 15:11 Desktop-out.mkv
:) vid $

hth & hf


EDIT:
What i'm saying is:
The more files you have (to rename), the more important it is to PRE-view the changes that will be done.
And having the strings aligned left and right of the screen/window just helps to compare, rather than having a list that is just space delimited. imho

All you need to do is to define a 'prefix' string, and add it in front of RudiC's example.

Last edited by sea; 05-06-2015 at 12:43 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with multiple file rename - change case of part of file name

Hi there, I hope someone can help me with this problem : I have a directory (/var/www/file/imgprofil) which contains about 10000 JPG files. They have a naming convention thus : prefix-date-key-suffix.jpg they all have the prefix p-20050608- then AAAA is a 4 letter code the suffix is... (7 Replies)
Discussion started by: steve7
7 Replies

2. UNIX for Dummies Questions & Answers

Editing multiple file names in one go

Hi there, I have a folder full of pdf's and I've run a compression on the to reduce the size, the output of the compress places a '-o' in the name of the file. Before 12345.pdf After 12345-o.pdf Now I've got around 50000 files that I need to change back to the previous name, is... (3 Replies)
Discussion started by: KeesH
3 Replies

3. Shell Programming and Scripting

Find and rename long file names (html)

Hi Guys, I need a help. I have 1130 zip files. Each one of them has files including 1 html file with long file name (includes special charactors, Alphabetic and numbers). I have copied all 1130 zip files to my linux system and extracted using below command. Find . -name "*.zip" -exec... (7 Replies)
Discussion started by: Rajmani
7 Replies

4. Shell Programming and Scripting

Change multiple file names

Hello, I have some files in a directory like: 01_07_2010_aa.txt 01_07_2010_bb.txt 01_07_2010_cc.txt 01_07_2010_dd.txt 01_07_2010_ee.txt 01_07_2010_ff.txt I want to change their names to : 3nm_aa.txt 3nm_bb.txt 3nm_cc.txt 3nm_dd.txt 3nm_ee.txt 3nm_ff.txt (8 Replies)
Discussion started by: ad23
8 Replies

5. Shell Programming and Scripting

Rename multiple file names in a directory

I hope some one can help me I have multiple files in a directory with out extension like as below mentioned. But i want to change all the file names along .DDMMYYYYHHMISS format. And all files should have same DDMMYYYYHHMISS. Scenario: direcory name = /vol/best/srcfiles files in a... (4 Replies)
Discussion started by: hari001
4 Replies

6. Shell Programming and Scripting

change multiple file names

Hi is it possible to change multiple files (~10k) names with out disturbing the data in it. ? input Hynda|cgr10(+):100027702-1000312480|.txt Hynda|cgr10(+):100027702-1000312483|.txt Hynda|cgr10(+):100027702-1000312484|.txt Hynda|cgr10(+):100027702-1000312482|.txt output... (4 Replies)
Discussion started by: quincyjones
4 Replies

7. UNIX for Dummies Questions & Answers

Multiple file rename

hi im new to linux and was just wondering if some 1 could help me i have folders with T.V. series in them and i would like to delete part of the filename e.g. (series name).s01e01.(episode name) (series name).s01e02.(episode name) (series name).s01e03.(episode name) (series... (4 Replies)
Discussion started by: stevemcd1990
4 Replies

8. Shell Programming and Scripting

Multiple file rename

I've been googling for days but can't find a solution to this problem. I have a number of sets of files on a server file02.dat . . file12.dat /.../fred(1 to n)/bill(1 to m)/tony/joe/ in any "fred" branch there will be one or more "bill"s some joe/'s may not have a fileset and... (4 Replies)
Discussion started by: Sabreur
4 Replies

9. Shell Programming and Scripting

Trying to do multiple dir's and multiple file names etc.

What am I missing? find: 0652-009 There is a missing conjunction find: 0652-009 There is a missing conjunction find: 0652-009 There is a missing conjunction find: 0652-009 There is a missing conjunction find: 0652-009 There is a missing conjunction find: 0652-009 There is a missing... (3 Replies)
Discussion started by: xgringo
3 Replies

10. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies
sysman_intro(8) 					      System Manager's Manual						   sysman_intro(8)

NAME
sysman_intro - Introduction of SysMan applications DESCRIPTION
SysMan is a suite of applications for managing Tru64 UNIX systems. The SysMan applications provide a simple, easy to use, graphical user interface (GUI) for common system management tasks including installation and configuration. When you follow the installation instructions in the Installation Guide, the installation GUI, Installation Setup, is displayed automati- cally. To help you prepare the system for general use, the Tru64 UNIX: System Setup checklist is displayed when you log in as root for the first time after performing an installation. SysMan applications and help are available from the Application Manager (tool drawer) icon on the CDE front panel, or from the SysMan Applications panel above the SysMan Station icon on the root CDE window. For additional information, see the Welcome to SysMan help volume by performing the following procedure: Click on the Application Manager icon (the file drawer) on the CDE front panel. Double click on the System_Admin application group icon. Double click on the Welcome to SysMan icon. If you are not running CDE, but have installed it, you can open the Welcome to Sysman help volume by entering the following sequence of commands at the command line: /bin/sh PATH=$PATH:/usr/dt/bin export PATH DTHELPSEARCHPATH=/usr/dt/appconfig/help/C/%H export DTHELPSEARCH- PATH DTUSERSESSION=${USER}-`uname -n`-0 export DTUSERSESSION dthelpgen -dir $HOME/.dt/help/$DTUSERSESSION dthelpview -helpVolume browser SEE ALSO
Commands: bttape(8), bindconfig(8), diskconfig(8), dxaccounts(8), dxadvfs(8), dxarchiver(8), dxdw(8), dxfileshare(8), dxhosts(8), dxkernel- tuner(8), dxlicenses(8), dxlsm(8), dxpower(8), dxpresto(8), dxproctuner(8), dxshutdown(8), dxsysinfo(8), mailconfig(8), mailusradm(8), net- config(8), nfsconfig(8), printconfig(8), sysman(8), System Administration Release Notes Installation Guide Technical Overview X Window System Administrator's Guide Network Administration Common Desktop Environment: User's Guide CDE Companion Common Desktop Environment: Advanced User's and System Administrator's Guide Common Desktop Environment: Programmer's Overview Common Desktop Environment: Programmer's Guide Common Desktop Environment: Help System Author's and Programmer's Guide Common Desktop Environment: Style Guide and Certification Checklist OSF/Motif Style Guide sysman_intro(8)
All times are GMT -4. The time now is 10:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy