The rename tag refers to the action of giving a different name to either an existing file or to a copy of a file as part of some other operations (.e.g. remote copy, backup). Use this tag as well for questions related to the (perl) rename command.

learn more… | top users | synonyms

9
votes
7answers
8k views

Bulk rename, change prefix

How can I bulk replace the prefix for many files? I have a lot of files like TestSRConnectionContext.h TestSRConnectionContext.m I would like to change all them to CLConnectionContext.h ...
5
votes
2answers
278 views

Trying to do arithmetic in Perl rename tool (Debian)

Supposed I have five mp3 files: 01-trackfoo.mp3 02-trackbar.mp3 03-trackbaz.mp3 04-trackabc.mp3 05-trackxyz.mp3 Now I give a quick listen to the files (just mplayer on console will do the trick) ...
0
votes
2answers
816 views

File extension case sensitivity on CentOS [duplicate]

Possible Duplicate: How to clean up file extensions? I'm using CentOS. There are >10M images in one of my folders, which are furthur grouped into subdirectories. The issue is that some of ...
3
votes
2answers
1k views

How do I get this find and rename command to work with subdirectories? [duplicate]

Possible Duplicate: Recursive rename files and directories I have a large directory of music files that is often changing as files and directories come and go. My preference is to make sure ...
3
votes
1answer
1k views

Can't rename a directory that I own

I have a directory with a big load of sub directories. I own all of them, and the permissions are all 777. pascal@azazel /box $ ls -al total 147872 drwxr-xr-x 293 root root 12288 aoû 22 19:44 ...
27
votes
3answers
12k views

Why unix mv program doesn't need -R (recursive) option for directories but cp does need it?

This is a kind of "wtf?" question, so I'm sorry if I will disturb someone's vision of how things should be or if I will just annoy you with the "stupid" question. I always get messed up when need to ...
1
vote
1answer
152 views

Move some files on every dir to a different dir [duplicate]

Possible Duplicate: How can I move files by type recursively from a directory and its sub-directories to another directory? I'm quite new to Linux and specially to the shell and all of its ...
3
votes
2answers
394 views

rename randomly files on a USB device

I would like to rename all of my files of my USB device randomly. Indeed, in my car, my tuner has not the random function. I think I can do it with PHP ... but I'm pretty sure it is possible to do ...
3
votes
5answers
523 views

Flatten Directory but Preserve Directory Names in New Filename

How can I flatten a directory in the following format? Before: ./aaa/bbb/ccc.png After: ./aaa-bbb-ccc.png
4
votes
2answers
3k views

Remove prefixes from filenames

I have a bunch of files as follows: 04602635_b0294.DAT20120807164534 04602637_b0297.DAT20120807164713 04602638_b0296.DAT20120807164637 04602639_b0299.DAT20120807164819 ...
4
votes
1answer
265 views

xterm doesn't switch directory when it is moved

Recently I was very frustrated with xterm not behaving as expected. This is what I was doing: open xterm run the following commands: $ mkdir test_01 $ cd test_01/ $ echo 'a' > a $ cat a The ...
1
vote
1answer
444 views

rename files maching specific mtime value within directory

I use simple set of shell commands to in order to create mysqldumps daily. The script is called by cron daemon. It looks like: presentdate="`date +%d-%m-%Y_%H:%M.%S`" basedir="/var/db_my_backup" ...
3
votes
3answers
3k views

Rename multiple directories

I want to find all directories with the last subdirectory named doc, for then rename them to Doc. How can be renamed? I've the first part: find -type d -name 'doc' which returns directories paths ...
2
votes
1answer
440 views

Detect file-type with the help of magic-file and rename file-suffix accordingly

I have a folder (the iPhone Backup) with various files without a suffix. I want to run a batch process over these files, which detects each file's file-type (with the help of the magic-file database ...
6
votes
4answers
5k views

Renaming a bunch of files with date modified timestamp at the end of the filename?

So, say, I have a directory with a bunch of files like g.txt, where g.txt was last modified on, say, June 20, 2012. How would I batch-rename all of the files (like g.txt) with the last modified date ...
17
votes
2answers
1k views

What does mv do in case of errors?

I've just tried to move a big tree from one disk to another, which was too small. Now, I'm left with something I can't really understand - it looks like some files were indeed moved away from the ...
3
votes
1answer
3k views

Gunzip multiple files and rename them

I want to know whether it is possible to gunzip multiple files and rename them with one command/script. I have a bunch of files in the format: test.20120708191601.DAT.3599502593.gz ...
4
votes
1answer
1k views

How do permissions work when moving directories?

Recently I tried to move a directory that I own to another directory (which I also own), but I couldn't. I then noticed that I don't own the parent directory. This made me wonder what are the rules ...
0
votes
2answers
2k views

How can I rename all files in the current directory having a particular extension to another extension? [duplicate]

Possible Duplicate: Renaming multiple files (changing extension) Suppose that in my current/working directory I have five files: file1.xvg file2.xvg file3.xvg file1.eps file2.eps Is ...
2
votes
1answer
202 views

prepend digit to filenames which begin with digits (with zmv, please)

I have a directory with files named like 19.png, 20.jpeg, and README00.txt I want to rename these to 119.png, 120.jpeg, and README00.txt. I would like to do this with zmv as it works well in so many ...
3
votes
2answers
1k views

How do I find a bunch of files with a string in its filename (or body text) and then move all those files to a specific folder?

Say - what if I wanted to move every HTML file in several independent directories with the word "heavengames" in its filename (and as a second question, every HTML files with the word "heavengames" in ...
1
vote
4answers
511 views

Recursively rename e-mail files from .txt to .eml

Directory "$d" contains a few thousand e-mail files with the .txt extension. To open them in my e-mail client, I need to rename them to .eml Will this command rename them correctly: find "${d}" ...
2
votes
3answers
9k views

Rename files by incrementing a number within the filename

I have a directory which contains numbered image files, something like this: 01.png 02.png 03.png 03.svg 04.png 05.png 06.jpg 07.png 08.png 09.png 09.svg 10.png Sometimes there may be multiple ...
10
votes
1answer
3k views

Best way to continue stopped move (mv) by merging directories?

I have moved (mv) a pretty large directory on my NAS (Linux based), but had to interrupt the procedure. Not being a regular Linux user, I though I could just continue and merge the rest later in. mv ...
1
vote
1answer
274 views

Switching source and destination (or undoing the mv, cp operation)

mv or cp commands both expect source and destination as arguments. In case you want to undo the change you made, or just change the source and destination you supplied before, what is the quickest ...
5
votes
3answers
686 views

Linux Rename File Beginning with “--” [duplicate]

Possible Duplicate: How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)? This is an awkward one, I have received some files from a windows machine ...
13
votes
5answers
933 views

How to remove the (1) from filenames using the find command

I recently converted all of my FLAC files to a lower sampling rate of 44.1 kHz and bit depth of 24 bits (because iPhone/iPod don't support anything above that) using XLD on my Mac OS 10.7 (Lion). ...
2
votes
2answers
5k views

Batch copying/moving files in unix?

Is there a way to batch copy/move files in unix? I thought it might be an option for cp/mv but I can't find any way to do it.
3
votes
3answers
2k views

Removing apostrophe from all file names

I tried to remove apostrophe from all files' names in the directory. for i in *; do mv $i `echo $i | tr -d "'"`; done After executing this command nothing is renamed. Do you know what's wrong ...
6
votes
4answers
2k views

Recursively rename subdirectories that match a regex

I have a media server with a folder called Series. (/media/Expansion2/Series/) In it, I have (surprise!) TV series. These are just the show names, e.g., /media/Expansion2/Series/The Big Bang Theory/ ...
5
votes
4answers
841 views

For each subfolder, sort files by name and rename them to sequential padded numbers (regardless of extension)

I have the following directory structure: . ├── event-a │   ├── album-a │   │   ├── a.jpg │   │   └── x.png │   └── album-b │   ├── a.jpg │   ├── x.png │   └── y.gif └── event-b ├── ...
3
votes
3answers
580 views

Unique file name for different files

I'm working with graphic design. I've downloaded many files (EPS files, PSD files, etc) from various websites. Because it come from various websites, after downloaded from more than 10 different ...
3
votes
2answers
4k views

Move huge number of files into date structured directory order

I have about 1 million files in this directory: /home/username/images/ Each of the files are called something like: 012345678910(Place)_0_20120414185957_28841.jpg with the timestamp part of the ...
2
votes
1answer
323 views

Renaming a bunch of files but keeping the number part

I have a bunch of files like this: pic100.png pig102.png box103a.png superb103b.png px103c.png rotor110 - new.png ready1323 (yellow car).png motorhome1036x red circle.png ... so, you can notice ...
26
votes
4answers
2k views

Quick way to include a directory path when calling mv? [duplicate]

Often I will work out of the root of a rails directory where I find my self navigating the same path twice every time I would like to move a file: mv app/views/layouts/application.html.erb ...
3
votes
3answers
585 views

pull out a file named to ~

So I have downloaded a music album from aMule and it is located in the .aMule/Incoming directory. I tried to move it out with the following command: mv albumName.rar ~ This left me with a file ~ ...
3
votes
2answers
2k views

UNIX move file name with sysdate

I want to make a script in Unix in which I have to move a file daily to a specific path. In order to avoid overlapping of the file, I want the file name along with the date. e.g. mv filename ...
3
votes
2answers
6k views

How to rename multiple files by removing the extension?

I have a number of tiff files named: sw.001.tif sw.002.tif ... and I want to remove the .tif at the end of each of the files. How can I use the rename command to do this?
1
vote
2answers
705 views

Bulk rename files with numbering

How do I bulk rename multiple files named Image401.jpg, Image402.jpg,... to Image 001.jpg, Image002.jpg, ... ?
2
votes
3answers
504 views

Rename a lot of files with all types of characters, with POSIX portability

Sometimes I need to rename all the files (the renaming convention follows later) in a directory where the filename is always in the form of 'filenamename.extension' (extension always exists and ...
1
vote
3answers
557 views

How to move files into newly created directory on condition in shell/perl

It was a mess of music files and directory. It is needed to perform the below operation over multiple directories at once: If the directory contains ".jpg" files, then create a new directory ...
1
vote
2answers
9k views

how can I rename multiple files by removing a character or string?

As a follow-up to my previous question, if I have multiple files of the form sw.ras.001 sw.ras.002 sw.ras.003 … What command can I use to remove the ras. in the middle of all the files?
3
votes
3answers
1k views

how can I rename multiple files by inserting a character?

I have many files of the form sw001 sw002 sw003 ... I want to insert a period between the sw's and the number values. How can I accomplish this?
1
vote
3answers
1k views

How can we rename a file with semi-colon as part of the filename?

I tried to rename all file with extension "XLS;1" to "XLS" but it just didn't work. I tried the following in cygwin in windows xp and they don't work: mv *.XLS;1 *.XLS mv *.XLS\;1 *.XLS mv ...
4
votes
6answers
3k views

Linux script or program to shorten filenames

I haven't had much success in finding a Linux version of namemangler, which I need to rename 1000 of files so they are readable on Windows. Does anyone know of a Linux program that can do this? If ...
1
vote
1answer
389 views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
4
votes
1answer
412 views

Renaming files from bash in linux

There is a bunch of files of the following format hh-mm-ss.png where hh, mm, ss are hour, minute and second. How can I rename all these files in the directory in a sequential way from 1.png til n.png ...
1
vote
1answer
1k views

Insert selected filename while copying in Midnight Commander

Is it possible to paste the selected filename into the copy popup, so when I hit F5 this filename will be in the 'to' section, so I can adjust it? For example: I want to copy ...
2
votes
1answer
123 views

/etc/rc*: Why does this command stop NFS services from starting at boot?

I recently found this home networking tutorial surprisingly enlightening. However, there is one thing I don't understand: Disabling NFS Start On Boot: If you are not planning on regularly ...
7
votes
3answers
13k views

How can you move (or copy) all files of a certain type to a directory in Unix?

I'm not very familiar with all the tricks of grep/find/awk/xargs quite yet. I have some files matching a particular pattern, say *.xxx. These files are in random places throughout a certain ...