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
1answer
33 views

renaming files in a folder

In one directory I have many files which look like this: Galaxy100-[0025-CL3.single.bed].bed and I would like to change it to: 0025-CL3.single.bed I tried this rename 's/Galaxy[0-9] - \[//' *, ...
1
vote
3answers
68 views

Bash script to fix file names

I have hundreds of folders with thousands subdirectories and files inside of them. The file names are currently in the format sf{number}-{number} - {text} and I need everything deleted until ...
1
vote
7answers
55 views

Rename files add dashes after fourth and sixth characters

I have some files such as: 20150716_something-here 20150716_something-heretoo 20150716_something-hereaswell They need to be renamed as 2015-07-16_something-here 2015-07-16_something-heretoo ...
0
votes
1answer
59 views

inserting modified date into filename - 2 cases

I believe I'll ask two separate questions, but the context is the same, so I hope it's alright. I have an output of few processes as presented below (which I can't modify). 25978.csv 26044.csv ...
3
votes
1answer
53 views

Rename files based on JSON content

I have two sets of files; file1.txt file1.json file2.txt file2.json file3.txt file3.json ... fileN.txt fileN.json json files contain the following format: {"ago": "59 sec ago", ...
1
vote
4answers
38 views

rename the 10 most-recently modified files on AIX

I have some .xls files in a defined directory (say in /A/B). I want to rename top 10 latest files and append "-bkp" in their names. I tried, not working ls -lt *.xls | head -1 | awk '{print "mv " $9 ...
1
vote
3answers
54 views

How can I recursively replace a string in file and directory names?

I have a git clone of etckeeper, and I'm trying to rename all files and directories with etckeeper in the name to usrkeeper. For example, ./foo-etckeeper-bar should be renamed to ./foo-usrkeeper-bar. ...
0
votes
3answers
59 views

How to batch rename files using loop combination in bash?

I have 2 folder structure like this: SOURCE_FOLDER_W_GOOD_NAMES ├── A_some_name.png ├── B_another_different_name.png ├── C_just_another_too.png └── D_this_one_stop_this_example.png Another folder: ...
1
vote
2answers
62 views

BASH file mass rename with counter

I want to rename all the files in a folder with PREFIX+COUNTER+FILENAME for ex. input: england.txt canada.txt france.txt output: CO_01_england.txt CO_02_canada.txt CO_03_france.txt ...
1
vote
1answer
26 views

Ubuntu shell curly brace expansion - confusion with sox command

I'd like to search through multiple subdirectories and convert all .mp3 files to .al files. Here's how I do it: find . -name '*.mp3' -type f -print0 | xargs -0 -t -r -I {} sox {} -r 8000 -c1 -e a-law ...
1
vote
2answers
51 views

How to rename certain directories if the parent has a particular name?

I have to do some global renaming in an Eclipse plugin project, although the fact that the code is Java and it's an Eclipse plugin is irrelevant. Basically, the steps I need to perform are the ...
1
vote
2answers
34 views

Rename all the files with a specific extension in all the subdirectory [duplicate]

I have a lot of directories. Each one of these has a file with a specific extension .ext. I want to rename these files. Example: // Note: The names are random, can have spaces and special ...
1
vote
3answers
39 views

Rename all the files in a folder such that it removes the text between two same characters

I have huge number of files in folders whose names are as following: abc.test.txt edf.main.txt num2.tb.doc file3.map.csv file4.test.csv I would like these files to be renamed such a way that the ...
0
votes
1answer
62 views

Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?

On CentOS, the rename command uses two simple strings, from and to. rename from to file... while on Debian/Ubuntu it uses a perl-style regular expression. rename [ -v ] [ -n ] [ -f ] perlexpr [ ...
1
vote
3answers
43 views

Rename only one file in each directory, based on condition

I have 100 folders inside every folder I have one or two files named as the following: XXX_001_014_max.jpg XXX_001_024_max.jpg I saved the folders names in a file "list.txt" I ran the following ...
1
vote
0answers
22 views

How to remove a single quote from a file name? [duplicate]

I have some podcasts on my radio server which contain a timestamp when they should be played. I noticed one of them is put into single quotes 'filename.mp3', and I'm unable to remove them. Check this: ...
0
votes
1answer
21 views

Why find is not finding some folders with spaces?

find -name "* *" -type d | rename 's/ /_/g' For instance, 'Paired End' folder name on this path is not being replaced with spaces: ...
0
votes
0answers
24 views

shortening a mv command to loop through multiple files [duplicate]

I used the following command to rename multiple files in different subdirectories. They all initially had a common name sample....., and I wanted to replace the word sample with a specific name for ...
1
vote
2answers
94 views

rename multiple files in multiple directories using Bash scripting

I want to rename multiple files in multiple directories using Bash scripting. I have 772 such directories i.e from Nishi_001 to Nishi_772. Each directory has different number of files in it but in ...
0
votes
1answer
32 views

Minimum file permissions to rename file

I put a 64-bit ELF file in my unprivileged user's home directory. I wonder which permissions do I need to have only possiblity to rename this file being logged in as unprivileged user. From what I ...
0
votes
1answer
22 views

Output NamingVariable for Multiple Files in Bash Script

I have a script I've created that will pad a series of Jpgs, create a subdirectory in the working directory, move the padded Jpgs to the subdirectory, change to the subdirectory, and then use ...
1
vote
1answer
36 views

Rename hundreds of files

I'm using Elementary OS (still very new to any UNIX system) and have hundreds of text files on my old hard drive that I need to sort. All text files have a name such as; lua - eng1-6TH4eI8gtf3.txt ...
0
votes
3answers
76 views

Remove all special characters recursively from filename [duplicate]

I have multiple files in directories and subdirectories that have special characters not supported by Microsoft file shares and SharePoint. The types of characters run the gamut from tildes to ...
0
votes
2answers
85 views

Move log file which is older than 2 days

I want to move log files which are older than two days to a new directory by date, like below. Source: 1) /Test1/Server.log 2) /Test1/Server17032016.log Destination: ...
2
votes
1answer
49 views

Convert order for find … -exec

I want to rename files and directories. Let's suppose that I want to convert every ä to a, and I have Järjestelmä/Säätimet. So I say something like find -exec rename 's/ä/a/g'. Now find will convert ...
0
votes
2answers
48 views

using sed to modify all files in a directory and name the outputs accordingly

I want the sed command to work on all files in a directory and output the result into a new file. If f is val1.txt, the name of the output file should be val1_ended.txt -this is what I am trying to do ...
8
votes
2answers
1k views

Why did mv delete a file with mv id_rsa *.old? [duplicate]

I wanted to backup my ~/.ssh/id_rsa to id_rsa.old, and it looks like it got deleted! How is this possible? :) root@localhost:~/.ssh# ls -l total 16 -rw------- 1 root root 3326 Mar 12 11:22 id_rsa ...
-3
votes
2answers
86 views
1
vote
2answers
72 views

Rename files in a directory

I have the files names as below in a directory example1.1.timestamp(.1457644337) example1.2.timestamp example1.3.timestamp and so on about 100 files. I need to rename all the files by removing the ...
2
votes
4answers
60 views

move a file that matches a pattern in a shell script

I have very little experience in writing shell scripts and need advice on how I can accomplish the following task. I need to move the most recent file in a directory where the filename matches a ...
1
vote
1answer
67 views

Rename multiple files in multiple directories to the name of the directory plus 1

I have been attempting to rename a bunch of files to their directories. I have multiple directories with spaces and no spaces /The Dark Tower. In it are multiple titles with file names with spaces ...
2
votes
3answers
173 views

Find and rename files (including directories) whose filenames contain space [duplicate]

I have quite a number of files and directories with spaces in their filenames in my ext4 filesystems. How should I safely find and rename them? I have bash and am running Ubuntu. Is it possible ...
1
vote
2answers
92 views

Renaming Files and Directories Recursively using rename/find

I started learning linux on vmware using centos 7. I created an image directory and several layers of files and sub-directories in that folder. most of the names containing spaces. I want to use a ...
0
votes
1answer
55 views

can mmv rename files by incrementing an index?

Can mmv, a mass move utility, nicely rename files from: foo.txt bar.txt baz.txt to: 1.txt 2.txt 3.txt The man page is intriguing, but I don't quite follow the directions: Rename all ...
0
votes
2answers
32 views

Bulk rename, change suffix? [duplicate]

How can I bulk replace the suffix for many files? I have a lot of files like NameSomthing-min.png NameSomthing1-min.png NameSomthing2-min.png I would like to change all them to NameSomthing.png ...
2
votes
1answer
48 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
vote
2answers
59 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 ...
-1
votes
1answer
17 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 - ...
1
vote
4answers
49 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 ...
1
vote
2answers
25 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
46 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 : ...
3
votes
3answers
79 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 ...
2
votes
4answers
152 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
72 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 ...
2
votes
3answers
200 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
15 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
72 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
63 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 # ...
1
vote
2answers
38 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
564 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 ...