Questions tagged [rename]

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.

Filter by
Sorted by
Tagged with
2
votes
3answers
343 views

Batch rename file by substring the filename

I have files .. 00016_0912RP10R6_RampMotorway9_0912RP10R6_13.646852_100.687103.jpg 00017_0912RP10R6_RampMotorway9_0912RP10R6_13.646956_100.686897.jpg 00018_0912RP10R6_RampMotorway9_0912RP10R6_13....
0
votes
1answer
171 views

using Find -exec to rename a file with the grepped contents of the file

I'm attempting to get a list of files with find and then use pdfgrep to get a string from the file, then rename the file with that string. The commands broken down are: find . -name "*...
0
votes
0answers
26 views

How to swap order of extensions of matching files? [duplicate]

I am merging two folders with the following command: rsync -a --checksum --backup --suffix=.merge-bkup src/ dst/ The idea is that if a file exists in both folders, both versions are preserved. ...
1
vote
1answer
357 views

Bash - Recursive directory/file rename

I have the following script, that will replace all spaces in files and directories recursively: ################### SETUP VARIABLES ####################### number=0 # Number of ...
0
votes
1answer
67 views

How to trim the tail number of the file via shell script?

I have the files as below. There are four files in total: cert1.pem chain1.pem fullchain1.pem privkey1.pem I want to trim the tail number of each file (1 here). How do I use a shell script to ...
1
vote
2answers
419 views

How to find/replace characters in a folder name?

I want to perform the following operations: Find/replace (using regexp) all occurrences of <>:"\|? and replace it with an empty string Find/replace (using regexp) all occurrences of ^\.+|\.+$ ...
0
votes
2answers
28 views

Renaming directories with specific extensions

An extension to the previous question that I asked: Rename an alphanumeric file I have a directory that has subdirectories with an extension of *_upstream: DHX30_vs_Control18....
4
votes
2answers
837 views

Is mv atomic operation between two file systems?

Is moving a file via the mv command between two filesystems an atomic operation?
2
votes
1answer
567 views

is there a way to atomically move file and directory from tempfs to ext4 partition on eMMC

We have beaglebone black based custom board with 256MB RAM and 4GB eMMC. Board runs Linux kernel 4.9 we are running into a situation where we create a file in tempfs and then after validation, we ...
1
vote
1answer
32 views

Inline replace comments in files recursively

I have tried using the cloc tool with the --strip-comments parameter, which is correctly stripping the comments from all files recursively, with 2 issues: it cannot do it "in-place" the resulting ...
3
votes
3answers
230 views

Rename an alphanumeric file

I have following files in a directory: GE.AARS_vs_Control16.txt GE.DHX30_vs_Control18.txt GE.DNAJC2_vs_Control18.txt I would like to remove the *_Control<numeric> and replace it with *...
1
vote
2answers
54 views

How can I copy a file and paste it as a different name?

I have a file test.txt in directory A/B. I want to copy test.txt to A/C and rename it newtest.txt. I know I can use the cp and mv commands to do this, but the issue is that there already is a test....
0
votes
3answers
44 views

Rename multiple directories using rename command, name involves parenthresis

I've got a list of directories marked with "(Done)" at the end of the label. For example: "Folder 1 (Done)" I'm looking to remove "(Done)" from each directory using the rename command. Because it's ...
3
votes
3answers
47 views

Copy files under modified name

I have to find all files in a directory ending by number (this part is OK) and copy them under a modified name (I don't know how to do this part). Typically: find $folder -maxdepth 1 -type f -name '*-...
2
votes
1answer
85 views

Need help with the rename command in Linux

I have several files with these names: file1, A.ext file1, The.ext I need to change there names as A file1.ext The file1.ext That is I need to move the article from the end to the beginning ...
0
votes
2answers
231 views

What is the best way of getting rid of a symbol (question mark) in hundreds of FLAC files

I recently ripped my 600+ album collection to FLAC, and up until now i never noticed there was something wrong with the files. See the files themselves look normal viewing them from within Mint. And ...
0
votes
2answers
254 views

Rename all files in a directory to add a leading zero - for filenames with varying 'stems'

I have a directory that has a large number of files. These files are named according to the following system: "Var1_X_Var2_Y_Var3_Z_data_N.txt" Where X, Y, and Z are many different numbers, and N ...
2
votes
2answers
577 views

Move last part of filename to front

I have several files named like this: This is a test - AB12-1998.avi (the last code is always 2 letters, 2 numbers, dash, 4 digits) What I'd like to do is rename them like this: AB12-1998 - This is ...
-1
votes
1answer
73 views

Rename multiple files with spaces and prepending a number to the filenames in bash

This is a list of files I have: $ ls -rt1 First Day in Tokyo.mp4 First Day in Seoul.mp4 Second Day in Beijing.mp4 Third Day in Bangcock!.mp4 Last Day in Singapore.mp4 $ What I want is: 01. First ...
5
votes
3answers
873 views

Are two subdirectories with the same root guaranteed to be on the same mounted file system?

A cpp file I'm working with creates a directory, i.e. mkdir( path, ... ), where path comes from an environment variable (e.g. getenv( "FOO" );). As an example, say $FOO is /foo, and path, created ...
1
vote
0answers
46 views

Rename file custom pre/post-fix string and date followed by any space trim [closed]

I have gone through various solution for renaming but none of them found fit in this situation. I have to rename a file oldfilename to newfilename with conditions like Prefix the hard coded string ...
3
votes
4answers
512 views

How to rename tar.gz files based on their match in the text file

I have many tar.gz files in a folder on my Linux machine and also text file with tar.gz file names and matching sample names. Current_directory |_______TDF.tar.gz |_______DFG.tar.gz ...
-1
votes
1answer
295 views

add date to existing filenames [closed]

I have multiple files at various locations in my home directory. abc1.txt abc432.txt abc3123.txt abc.txt abc988822.txt I want to add date to these filename without changing the original names. ...
0
votes
2answers
126 views

Remove particular word from filename

I have many files in a single folder like compose_icon_200x200.png mail_icon_200x200.png attach_icon_200x200.png delete_icon_200x200.png I want to remove the _200x200 from all filenames. I have ...
0
votes
2answers
87 views

Change extension of all file names containing specific string

When I get a file whose name contains the string "x264", I wish to change its extension to ".mp4" (for reasons too detailed to explain here). Examples: Seinfeld_S02E05_x264.mkv -> ...
1
vote
2answers
842 views

compress file using /bin/gzip with particular patterns

I want to compress files individually with the particular pattern. For example, I have directory as below : /log/log1 -/1/log2/file.1 -/1/log2/file123 -/1/log2/file2.1 /log/log2 -/2/...
-1
votes
1answer
52 views

Rename a text file name

I have several text file and extract a few of the file name as shown below DFC_2_31A_K14_G008_F2_001D.txt DFC_2_31A_K66_G005_F1_001D.txt DFC_2_31A_K66_G005_F2_001D.txt DFC_2_33_I_K15_G001_F1_001D.txt ...
1
vote
1answer
614 views

Rename files with specific extension and append date in unix

I want to rename below files as follows. Original files : x.1.gz y.1.gz Rename it to x.dateTime.gz y.dateTime.gz I am using following script to do the same. But it is deleting files instead of ...
0
votes
2answers
86 views

How to append TEXT inside a text file to the END of the file name of a different file?

I have figured out how to download multiple images from flickr.com and save the tag info to a separate text file alongside the image file. For example: $ ls 2675.jpg 2675.txt $ cat 2675.txt ...
0
votes
1answer
45 views

To Make File name according to their IDs

I want to replace each file name with their specific IDs. My files are 30,000 and so their respective IDs. Can it be possible to fetch ID which is inside in each file on line number 2 and become a ...
0
votes
1answer
89 views

Create new concatenated files of same name in multiple directories

I have many files of the same name distributed in many sub-directories with different names (though all at the same level). I'd like to concatenate all the files of the same into a new file with that ...
-3
votes
3answers
874 views

Rename Files with increment Numbers

I have files in /root/test/access.log.1 to 999 and /root/test/error.log.1 to 999. I would like to rename access.log.1 to access.log.2 and move to /var/log/archives/, and same way error.log.1 to ...
-1
votes
2answers
125 views

Renaming a file and appending a digit if a file already exists

I want to write a script that will rename a file and append a digit at the end if a file already exists. mv a.txt b.txt Since b.txt already exists, b.txt.1 will be the renamed file and if i do it ...
0
votes
2answers
68 views

How to make a function in bash that insert a new filename between others?

Suppose, I have a directory called Titlepage that have many files named titlepage_1.pdf, titlepage_2.pdf ... titlepage_n.pdf and their tex files also. I have a bash function that alter two filenames.(...
0
votes
2answers
30 views

Renaming files by removing compiler stamp

Given list of directories, e.g. dirs="Larry Curly Moe" compiler vendor, e.g. -gcc-M.N.0 the goal is to sweep through each directory and truncate all file names like so: intel-mkl/2018.1.163-gcc-...
0
votes
2answers
274 views

How to rename files recursively in sequential order?

I'm going crazy here. I have a lot of folders like this Folder 1/ Subfolder 2/ Item.01 Item.02 Subfolder 3/ Item.01 Item.02 I want to rename all files inside the folder 1, recursively and ...
0
votes
2answers
37 views

Using Perl's rename with groups [duplicate]

I've a set of files named in the following manner: _9978967868768763ghjgj7598983678hjva_week1-6.pdf _78637832bdsjh275637bkkaww786b_week12-32.pdf 8786767867868978713bkwkhjhkjqw_week1-622.pdf ...
0
votes
1answer
62 views

renaming a number of files by increasing their trailing number by a constant using bash script [closed]

I have these files in a directory: mmm.1 mmm.2 mmm.3 . . . . . i want to rename them as: mmm.31 mmm.32 mmm.33 . . . Just adding the number '30' to the trailing number in each file name.
0
votes
2answers
245 views

Recursively move specific files in nested directories to a name derived from the path

I have some files in different nested directories. All the files are named Analysis.mzXML. I would like to have them all in one place, while changing the name of each one to something different, ...
0
votes
1answer
136 views

Trying to rename .xml files in unix directory [duplicate]

I have around 5000 .xml files in my unix directory. I want to add extension Hist to all the file names before .xml extension. For example if the file is ABCD.xml, I want to rename it to ABCDHist.xml. ...
0
votes
1answer
194 views

Command line to change file names

I have a large number of files which I would like to rename. Here is an example of how I would like to change the file names: From: PD5 grey nice display 1.jpg To: pd5-grey-nice-display-showcase-1....
0
votes
2answers
56 views

Renaming multiple files with 2 consecutive periods within name

I need to use the rename command to rename hundreds of files which contain .. (2 periods) within the filename and change .. to - (hyphen). The fact that it contains periods seems to be confusing the ...
2
votes
0answers
387 views

udev iw add interface rename issue

I need to put wifi interface into additional monitor state. If I don't use udev rule and wifi interface named by kernel as wlan0 (default): $ iw dev wlan0 interface add mon0 type monitor in this ...
0
votes
2answers
116 views

Rename characters within a specific file using find and variables?

I have a file that looks like the following: /var/www/html/media/2018@03@01@vi_0005_20180301_110203.h264.v0005.th.jpg. I would like to find this file in /var/www/html/media and rename h264 to mp4 ...
0
votes
3answers
245 views

Find and replace a string in a batch of files but do not create any filename conflicts

I have a directory tree with a few thousand files collected over the years with random and useless file names. I want to clean them up, keep them relevant, remove certain words but also not create ...
0
votes
2answers
419 views

UNIX foreach and sed commands!

I have 7 csv files which have some climatic data. The name of the files are: SMVV50065-2015-01.csv and *2015-02.csv, 2015-03.csv etc. When I open the csv files I see a syntax like this: " SMVV, 2015-...
0
votes
2answers
1k views

How to rename multiple files using find and rename

I want to take out .hs from all files. Why this command doesn`t work properly? It leaves the same name of files. find . -type f -exec rename .hs ' ' * \;
0
votes
2answers
144 views

Renaming a list of files from a text file

I have a folder containing these list of files. lesson1.mp4 lesson2.mp4 lesson3.mp4 lesson4.mp4 I`m trying to rename this files based on contents of "rename.txt" 1. Introduction to the React ...
0
votes
4answers
510 views

How to remove `_` from all file-names in a directory

In bash, I have an unzipped directory where I have many file names that start with _. I'm pretty sure I can use rename or mv to simply remove the _ prefix of each file that has it. I try: for ...
0
votes
2answers
35 views

rename filenames recursively to simpler name [closed]

my file names look like: A06_S6_L001_R1_001.fastq A06_S6_L001_R2_001.fastq B07_S6_L001_R1_001.fastq B07_S6_L001_R2_001.fastq C08_S6_L001_R1_001.fastq C08_S6_L001_R2_001.fastq and I want: 1A06.R1....