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

1
vote
2answers
38 views

How to remove prefixes and suffixes from filenames in a given directory?

I have many files with the same prefix and the same suffix. I want to remove both from filenames. Both contain spaces. So foo bar XXX doo par.jpg, foo bar YY YY doo par.jpg would become XXX.jpg and ...
2
votes
1answer
38 views

Adding folder name to .zip files inside it

I have file1.zip, file2.zip, etc. in folder called folder1. have similar folders folder2, folder3, etc. I need to add folder name to each .zip file inside these folders. So, files inside folder1 ...
-1
votes
1answer
14 views

renaming txt files

I have a list of files named like this SLX-11025.N701_N504.C8912ANXX.txt And need to rename them based on this small part N701_N504, and each will be renamed to an specific code (for example - ...
0
votes
4answers
38 views

Rename files randomly but without repetition

Suppose i have a folder with a lot of file names some very strange and nonsense I want to rename it like File-1 File-2 File-3 .. I have tried this(echo is for tryng) for name in *; do echo mv ...
4
votes
2answers
1k views

Replace a substring of filenames in a directory

There exists a directory, which includes several levels of sub-directories. Under these directories, there are a set of files whose names include a common word, e.g, .cc. How can I replace the .cc ...
0
votes
2answers
22 views

Batch rename long filenames of variable length with years

I have a bunch of files in a single directory that I would like to rename as follows, example existing names: 1937 - Snow White and the Seven Dwarves.avi 1940 - Pinocchio.avi Target names: Snow ...
2
votes
2answers
37 views

Renaming a file the moment it appears in a folder

Here's the context : on a samba server, I have some folders (that we'll call A,B,C,D ) which are supposed to receive files from a network scanner. The scanner renders a PDF file named like this : ...
4
votes
4answers
14k 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
3answers
44 views

backreferences in `rename` regex

I have A LOT of files named "bar_foo.txt" in a directory, and I'd like to rename them to "foo_bar.txt" instead. In sed and vim the regex to to this would be something like ...
3
votes
4answers
7k 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
4answers
95 views

Moving and renaming hundreds of .jpg files, all named 5003.jpg

So here's the deal, my girlfriend wants me to transfer all of her photos off from her iPhone onto her laptop (on which we are running Ubuntu 14.04). All of the dedicated programs I tried to do this ...
2
votes
2answers
69 views

How do I rename files using the directory name?

My file structure now is: Input 1 pre.nii 2 pre.nii I would like it to be: Input 1_pre.nii 2_pre.nii From the Input folder, I tried: for i in */pre.nii; do echo $i_pre.nii; done ...
3
votes
3answers
173 views

move middle part of filename to front

I have files named in the style 02.04.11 DJ Kilbot.mp3 (for several dates) and I want to reformat the name in this manner: DJ Kilbot 2011-02-04.mp3. In other words, the current format is MM.DD.YY ...
0
votes
1answer
12 views

rename all files in a folder deleting duplicate string-parts

I have a folder with lots of subfolders, that contain two times the same but slightly different: Movie1 {Action}{Adventure}{Sci-Fi}{Thriller}{Science Fiction}/ Movie2 ...
1
vote
3answers
52 views

Add extension to a list of files

I am trying to determine a perl method to add an extension to a list of files. I can already rename a list of files with a certain extension to some other extension, but I need to be able to do this ...
0
votes
2answers
60 views

mass renaming of files not working

Quite a few similar question are being asked. The error is probably staring at me in the face, but I just can't see it... #!/bin/bash declare -a files shopt -s nullglob files=(*) count=36 # ...
23
votes
3answers
4k views

How to rename file to .. (dot dot)?

Apparently you can rename file to .... If I were insane, how would I rename file to .. or .? Is such a filename even allowed? Backslash doesn't seem to disable dot's special meaning: $ mv test \. ...
1
vote
2answers
23 views

How to change the default use of detox, so it just doesn't replace spaces by underscores

I'm happy with the default usage of detox for sanitizing filenames, except I don't always want to replace whitespace with a single underscore. Would like to replace whitespace with a single space. ...
7
votes
7answers
542 views

How to rename splitfile[a-z] to splitfile[1-26]

I am trying to rename files named in the form of splitfile[a-z] to splitfile[1-26].csv, that is I want to rename splitfilea to splitfile1.csv and so on. I tried the following command: mv ...
5
votes
5answers
267 views

Rename files based on their parent directory using find/xargs command?

I have a directory structure like this: Project/ | +--Part1/ | | | +--audio.mp3 | +--Part2/ | | | +--audio.mp3 | +--Part3/ | | | +--audio.mp3 ... I want to ...
1
vote
3answers
61 views

Renaming thousand files with similar names

I'm having a difficulty creating a bash script to rename my files,so i'm asking for help. The files are in the same folder and all look something like this 1xxx_(bunch of characters)=(bunch of ...
11
votes
6answers
43k views

Rename multiples files using Bash scripting

I want to rename multiple files in the same directory using Bash scripting. Names of the files are as follows: file2602201409853.p file0901201437404.p file0901201438761.p file1003201410069.p ...
0
votes
1answer
38 views

Script for renaming files using text file containing alternate file names

I have a folder containing thousands of files: file1.jpeg file2.jpeg file3.jpeg etc. I have a text file containing a list of new filenames I want to substitute: old_filename new_filename ...
3
votes
7answers
3k views

Remove a specific extension from all the files in a directory

I have a couple of files with ".old" extension. How can I remove the ".old" extension without remove the file? I can do it manually but with more work: mv file1.key.old file1.key mv ...
2
votes
3answers
139 views

Replace underscores with spaces for all files in directory

For all files in a directory, I want to replace the underscores in the filename with spaces. I tried this solution, which does the opposite of what I want: ...
1
vote
1answer
16 views

Rename files to insert _ between StudlyCapsified words

I've a music lib where files names are like 05WithoutWallsSpanishMixChillDeLucia.mp3 (no space between words BUT exist a capital letter at beginning of every word). How do I detect this string form ...
3
votes
5answers
6k views

move file by list in file

I have a file that contains file names. For example: /tmp/list.txt (it is with the spaces at the start of each line): /tmp/file.log /app/nir/home.txt /etc/config.cust I want, using one ...
5
votes
3answers
106 views

Auto increment filename

I have a need to collect some duplicate files and want to avoid name collisions. The problem is that this collection of files might be added to by another execution of my script before the files are ...
1
vote
1answer
26 views

Why isn't this perl regex capturing the backreference?

I have a directory of files $ ls -1 ep2.mp4 ep3.mp4 ep4.mp4 ep5.mp4 ep6.mp4 ep7.mp4 I want to use the perl rename utility to make all files look like e.g. ep02.mp4 Command I am using rename -n ...
-1
votes
1answer
24 views

How to rename group files [duplicate]

How to rename a group of files tl_0014_0010_20151212_133443.jpg tl_0014_0010_20151212_133543.jpg tl_0014_0010_20151212_133643.jpg ... to photo00000.jpg photo00001.jpg photo00002.jpg ... ?
3
votes
1answer
64 views

move files based on pattern with zsh/zmv

How could I move files to subdirectories based on the common part of their names? For example, with files named as comment_LastName.pdf and comment_LastName.md and sub-directories named as ...
1
vote
1answer
34 views

Is it possible to rename a process you own from outside that process?

If I'm logged in as $USER, and I run top and I can see a process I own can I rename that process? If so, how? If not, can root rename a foreign process? If so, how? If not, why?
0
votes
0answers
33 views

Move files according to their name in corresponding folder only if the file does not exist already

I created a script that creates reports using R and Latex and that should move the reports to a designated location only if a report with the same size does not already exist there. The script looks ...
1
vote
3answers
49 views

Rename files in directory based on names of files on another directory

I'm not sure if this has been asked here but here is my problem. I have files in lets say dir1 named: File 1.mp4 File 2.mp4 etc.. Now on directory dir2, I have files named: Sub 1.srt Sub 2.srt ...
-2
votes
2answers
71 views

How to rename bulk of jpg files to png using convert

Let's say I have a bunch of .jpg files which I want to convert to .png. The file structure is as follow: 00-01.jpg 00-02.jpg 00-03.jpg 00-04.jpg 00-05a.jpg 00-05b.jpg 01-01.jpg 01-02.jpg ...
1
vote
5answers
117 views

How can I rename a file on unix using characters in filename?

I have a bunch of files in a unix directory that look like the following: filename_1234567.txt I need to rename them by copying the last three characters of each filename to the front of the ...
3
votes
2answers
65 views

How to keep exactly one file in a directory?

I have recovered files and currently they have this structure: root/MD5_of_file1/file1 root/MD5_of_file2/file2 ... root/MD5_of_filen/filen Obviously, duplicates are now in the same folder. The ...
0
votes
0answers
24 views

Nemo file renaming display glitch

When I try to rename a file in the Nemo file explorer it moves the name to the left so that about the first 5 characters are behind the sidebar. It looks like this: I'm currently running ApracityOS ...
0
votes
0answers
24 views

Error: rm /u01/sbldev01/siebel/siebsrvr/objects/esn/siebel_sia_OLD_20151110.txt: no such file or directory

I have a small sh that rename 2 files. However, when I try to download the file generated, I got the error: Error: /u01/sbldev01/siebel/siebsrvr/objects/esn/siebel_sia_OLD_20151110.txt: open ...
2
votes
3answers
297 views

Renaming files without file extensions

I have a series of files named KLLxxx (the x represents numbers). They're text files but have no file extension to them. Just files that say KLL followed by three digits. I want them all to end with ...
26
votes
6answers
111k views

How to move all files and folders via mv command

How can I move all files and folders from one directory to another via mv command?
48
votes
11answers
25k views

Batch renaming files

I have a directory full of images: image0001.png image0002.png image0003.png ... And I would like a one-liner to rename them to (say). 0001.png 0002.png 0003.png ... How do I do this?
0
votes
1answer
23 views

how can I target filenames with 2 digits with the rename tool?

I am trying rename files in a directory which have a 2 digit number - i.e. any and all numbers from 10 to 99. I want to prepend a 0 so that for example 23 becomes 023, so that files like this ...
34
votes
5answers
10k views

Quickest way to rename files, without retyping directory path

I know how to rename files in Unix: $ mv ~/folder/subfolder/file.txt ~/folder/subfolder/file.sh ^-------this part------^ ^------this part-------^ It takes too long time to repeat ...
3
votes
1answer
5k 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 ...
0
votes
5answers
93 views

Find all [filename].mp4 and rename [filename].audio [duplicate]

So I have a script that adds 2 films together using the audio from the $1.audio file. What I would like to do is rename any file in the directory with: *.mp4 To: *.audio Keeping original file ...
1
vote
3answers
131 views

Move files up by a directory by depth criteria

I have a directory tree that looks like this (simplified, in truth there are hundreds of folders): . ├── a │   └── b │   └── a.h5 ├── b │   ├── b │   │   └── e.h5 │   └── c │   ├── a.h5 │   ...
2
votes
5answers
127 views

Rename files not directories

I want to rename all files to lowercase in a directory without renaming subdirectories. I know rename function but it renames files and subdirectories which is not desired. Can you help?
11
votes
2answers
7k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
3
votes
4answers
202 views

How can I pad lots of file names with zeros in a directory?

I just wrote a script that generated hundreds of files and stored them in a directory ~/foo. These files are ~/foo/X-file where X ranges from X=1 to X=900. My problem is that I would like to view ...