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

4
votes
1answer
2k views

Batch copy and rename with regexp

I am wondering whether there is a way how to copy and rename a bunch of files without scripting. I have files with names like prefix_12345678901_12345678901_suffix.ext and I need to copy all of them ...
4
votes
2answers
209 views

Faster way to rename duplicate files (identified by fdupes) in another directory?

I have a directory full of pdf files of journal articles, most of which are named by their bibtex key. Some time ago I made a backup on an external hard drive, but I haven't kept it up to date and ...
4
votes
2answers
60 views

How to exchange words in a filename using the shell?

One of my customers is a school. On their file server all projects have a directory with the same naming scheme. <last name>, <first name> <second name>? - <project ...
3
votes
7answers
573 views

Batch renaming of files [duplicate]

I have a directory full of images: DSCN4749.JPG DSCN4750.JPG DSCN4892.JPG ... And I would like a one-liner to rename them to (say). dscn4749.jpg dscn4750.jpg dscn4892.jpg ... How do I do this? ...
3
votes
5answers
4k views

Rename all the files within a folder with prefix “Unix_”

Rename all the files within a folder with prefix “Unix_” i.e. suppose a folder has two files a.txt and b.pdf than they both should be renamed from a single command to Unix_a.txt and Unix_b.pdf
3
votes
3answers
3k views

How to move all files with a certain file extension from subdirectories to a single directory

I have a directory that contains many subdirectories. The subdirectories contain lots of types of files with different file extensions. I want to move (not copy) all the files of one type into a new ...
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?
3
votes
4answers
2k views

How to change extension of all files in a directory?

There are some extensionless files in current directory (there are not dot in their names). I want to rename like so: filename -> filename.md I tried doing mv * *.md but that didn't help. I am ...
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 ...
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?
3
votes
2answers
76 views

Trimming Filenames from the end

I have a folder with following mp4 file which are needed to be renamed for filename in /media/usama/CRUNCH/RO_Plant/RO_Videos/*; do File1=$filename echo $File1 done ...
3
votes
2answers
837 views

Move with possible rename

Is it possible to construct a command that will move the file to another directory and if the same file is already there, generate some random string that is not in the name of some file in the ...
3
votes
2answers
349 views

Moving large numbers of files and directories to a different directory

I'm trying to move the following move a large number of files that exist in the following structure to a /mnt/originals but I need to maintain the structure at the same time. I know cp would be a ...
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
3answers
733 views

Rename the last 8 characters in filename

I am receiving video files with different names but the final 8 characters of all are numbers (also different every time). This is the pattern of the file name: custom text 00030402.avi I have to ...
3
votes
3answers
501 views

Rename multiple directories decrementing sequence number?

I have a directory which contains a number of subdirectories with names on the format dir.##. The prefix is always the same, and the suffix is 1-3 digits in a strictly incrementing sequence. Thus, ...
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 ...
3
votes
6answers
4k views

Renaming multiple files based on their contents

How can I rename all files within a folder with the first word of their content? For example if a.txt contains “Unix is an OS” in its first line then a.txt should be renamed to Unix.txt
3
votes
3answers
78 views

Moving an open file to a different device

I have an application running that is generating a large (~200GB) output file, and takes about 35 hours to run (currently I'm about 12 hours in). The application just opens the file once then keeps it ...
3
votes
3answers
517 views

Shell Script to move folders containing a specific word

I'm searching for an simple shell script to mv all folders in /var/www/uploads/ that containing Math or Physics in the name to /mnt/Backup/. I've never done something like that before, due to the ...
3
votes
4answers
225 views

Batch file rename with substitution lookup

Using bash, how I can batch rename a large number of files, where I need to construct a new name for each file, based on its existing name and a 'contextual map' - don't know what else to call it – of ...
3
votes
3answers
628 views

Adding prefixes/suffixes to file names without typing it all over again?

I would like to do something like the following $ tmp=name* $ mv $tmp new_$tmp $ ls new_* $ new_name-with-stuff-i-dont-want-to-type name-with-stuff-i-dont-want-to-type Setting the environment ...
3
votes
3answers
496 views

Batch rename files with unknown names and unknown extensions

I have a bunch of pictures, some are .jpg, some are .png. any given picture could have an entirely random name (possibly including spaces). in any given directory, how can I rename all of them, ...
3
votes
1answer
2k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...
3
votes
2answers
11k views

mv: cannot stat No such file or directory in shell script

I wrote a script to move some files form one folder to another folder but I got the following error, I checked 2 folders and notice for 1 folder there are such files and another there is no such ...
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
155 views

zmv command to rename file after matching pattern

I was trying to figure out a solution for this question using zmv. I am unable to find an exact solution using zmv. This is what I could come up with so far. From here, I could rename all files like ...
3
votes
3answers
201 views

How can I use rename to recursively rename everyting to uppercase

I'd like to recursively rename all files and folders (sub-folders) to uppercase. I found some scripts that will do it to lowercase, but I don't know how to change them so it will do it the other way ...
3
votes
3answers
148 views

Change the name of a file that contains spaces in the name

I don't know why but when I go to change this file name with mv command it comes up with the error stating not a directory. -bash-4.1# mv {{ THEME SANITIZED }}.hacks.css myomega.hacks.css
3
votes
4answers
1k views

how to rename files while copying?

How would I copy (archive style where date isn't changed) all the files in a backup directory to the user's directory while renaming each file to remove the random string portion from the name (i.e., ...
3
votes
2answers
395 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
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 ...
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 ...
3
votes
2answers
653 views

Simple shell script needed to move database files

I am using MySQL on Ubuntu machine. I need to physically move around the database files under /var/lib/mysql/ (this is where all the databases directories are located). Say I have two databases, ...
3
votes
1answer
2k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
3
votes
2answers
386 views

Splitting a large directory tree by file type

I have a large data directory (20-30Gb) on my Ubuntu 10.10 desktop machine that consists of many raw data files, processed data files, and assorted scripts, tables, figures etc. generated from the ...
3
votes
3answers
494 views

Rename multiple files, sub directories, and insert characters at specific location on OSX

I have files and directories starting with "cateory-icon-" in many sub directories. I am trying to rename them recursively to "category-icons-". Please note that I added missing "g" to the category ...
3
votes
2answers
697 views

How to copy multiple files but keep their extensions the same?

I am looping through a number of files, and $file represents the current file. How can I make copies or renames and keep the extension the same for this current file? e.g. if $file = x.jpg How to ...
3
votes
2answers
2k views

Automatically moving files to a directory, one by one, and only when the target folder is empty

Is it possible? And in reverse alphabetical order? Essentially, this: How can I move files by type recursively from a directory and its sub-directories to another directory? Except that each file is ...
3
votes
1answer
2k views

When we use mv command, what changes take place in HDD?

Under following conditions- mv within the same HDD partition mv to a different partition in the same HDD mv to a different device (e.g. USB HDD) Is the complete file moved or is it a very small ...
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 ...
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 ...
3
votes
1answer
404 views

Multiple renaming files [duplicate]

Possible Duplicate: How to clean up file extensions? I'd like to rename files with extension .flac.mp3 to extension .mp3. I used the following command $ for i in *; do mv $i `echo $i | sed ...
3
votes
3answers
62 views

MMV mass file rename

I'm having trouble figuring an mmv pattern. I have a bunch of video files with this pattern: my.program.name.season.NN.episode.NN.-.title.avi and I need to move them to: ...
3
votes
2answers
332 views

Organizing messy folder based on filetype

I have music lying on my desktop and in my downloads and Music folders. Similarly, I have .odt files lying all over my home folder (mainly desktop). Is there a tool (preferably GUI so my parents can ...
3
votes
3answers
1k views

How do I remove carriage returns from directory names?

I created a file in Excel and ftp'd the file over to my Linux machine. In the file were a bunch of mkdir commands. Now all of the newly created directories have a carriage return at the end of them. ...
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
5answers
527 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
3
votes
4answers
2k views

rename character “â” of directory name?

I'm trying to rename rename character â of directory name to be blank. For example, directory with name how-â8093-to. This is the command I use, including some other modification find . -type d | ...