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
36
votes
9answers
137k views

how to rename multiple files by replacing string in file name? this string contains a “#”

https://serverfault.com/questions/70939/how-to-replace-a-text-string-in-multiple-files-in-linux https://serverfault.com/questions/228733/how-to-rename-multiple-files-by-replacing-word-in-file-name ...
-1
votes
2answers
48 views

Renaming file from a script? [duplicate]

I am creating a script which would enable me do something in a shorter amount of time. Is there a way that I can rename a file automatically from: WDMyCloud_plexmediaserver_1.16.1.1291.bin(07082019)' ...
-2
votes
4answers
70 views

How to rename multiple folders at once to remove certain characters? [duplicate]

How can I rename all these folders at once to remove "-v4"? My directories look like this: drawable-hdpi-v4/ drawable-ldrtl-v4/ mipmap-mdpi-v4/
2
votes
1answer
987 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 ...
1
vote
0answers
8 views

Issue renaming multiple directories within the same path [duplicate]

I'm still new to bash but I have the following short script find "somedirectory" -name "* - *" -d -not -path '*/\.*' | while read a do mv "$a" "${a// - / }" done The objective being to replace ...
0
votes
1answer
32 views

to apply counters on directories inside a folder

I've a folder structure like this: drwxr-xr-x 2 root root 4096 Jun 30 21:34 dir_0.0.1_2 drwxr-xr-x 2 root root 4096 Jul 2 23:45 dir_0.0.1_1 -rw-r--r-- 1 root root 24 Jul 3 00:03 a.sh drwxr-xr-x 2 ...
0
votes
1answer
32 views

Renaming 100 files in a directory to new file names stored in a text file

I have a list of 100 files in my working directory for example GCF_000021605.1_ASM2160v1_genomic.fa GCF_001887455.1_ASM188745v1_genomic.fa GCF_003719755.1_ASM371975v1_genomic.fa GCF_000021625....
0
votes
1answer
36 views

Move files to specific folders based on name

I have this file/folder scheme: /Aula /Aula01 /Aula02 aula-01.1.mp4 aula-01.2.mp4 aula-01.3.mp4 aula-02.1.mp4 aula-02.2.mp4 aula-02.3.mp4 All the mp4 files are located in the root directory (...
3
votes
1answer
4k views

rsync + renaming the copied files

Is it possible to change the name of the destination file (add some timestamp as a prefix) when copy is done by rsync ? For example, I can use the following command to change the name of the ...
1
vote
3answers
44 views

How to rename the multiple files within a directory

I want to rename the below files Var1DecoderBase.cpp Var1DecoderDerived.cpp Var1EncoderBase.cpp Var1EncoderDerived.cpp Var1Factory.cpp to Var4Config.cpp Var4CountDownTimer.cpp Var4DecoderBase.cpp ...
2
votes
3answers
626 views

Bash script to give random extension to the filename

I am trying to make a bash script for OSX that adds an alphanumeric extension at the end of the file. I can't find how to make the random 6 character. Ex filename_cod_45fg43.zip Here the script: ...
4
votes
3answers
1k views

Recursive copy files with rename

If I have input folder files_input that has subfilders like 01-2015, 02-2015, 03-2015 etc and all these subfolders have other subfolders. Each subfolder has only one file called index.html. How can ...
2
votes
4answers
1k views

Change part of the filename on multiple files in a directory:

I once had a script that would do the following. It would rename part of a filename of multiple files in the current directory: For example: rename variable1 variable2 rename 456 555 Input: ...
0
votes
1answer
30 views

Rename non alphabetical & numeric characters in files with nothing

I have a load of .jpg files in a folder that have non alphabetical characters like ! , ( ) ^ & . and more. I need to rename the files so that anything that is not A-Z a-z 0-9 is replaced with ...
0
votes
2answers
53 views

Sort and mv files based on filename (with spaces), recursively

I have made a mistake and dumped files together into the same directory. Luckily I can sort them based on the filename: ''' 2019-02-19 20.18.58.ndpi_2_2688_2240.jpg ''' Where the # bit or 2 in this ...
1
vote
3answers
46 views

Remove character pattern at beginning and end of filenames

I have a bunch of files that I'd like to rename. Their filenames are in a certain format: p1.uniquenameA#blah_a p2.uniquenameB#blah_b p3.uniquenameC#blah_c p4.uniquenameD#blah_d p5.uniquenameE#blah_e ...
0
votes
1answer
37 views

How to rename a bulk of files and remove extension

I am need to rename the below files. I only want to remove .job-209675 from the filenames that begin with SOA but keeping the original filenames intact as there are other files in this directory for ...
0
votes
5answers
87 views

Special “copy and rename” case

I have a deeply nested folder structure in which there are hundreds of files called data.log. I need a script to rename each of these data.log files according to the name of the parent folder they are ...
0
votes
2answers
51 views

how to detect files rename, without snapshot

I am currently monitoring directories with subdirectories, and I need to detect file rename. what I do is making a md5sum of all files and a keep a file list on another place, and from time to time ...
3
votes
2answers
106 views

Rename photos to match video titles

I have a mostly automated media server and currently have everything going into one folder and being sorted out by file extension into the correct locations. At the moment the photos are coming in ...
0
votes
2answers
49 views

Get filenames and write them on place of previous namespace

I have hundreds of sources codes files. I want to rename namespace according to the filenames path. Of course slashes must be replace by dots. I have tried with find -exec but I failed to get the ...
8
votes
5answers
15k 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 ...
12
votes
4answers
1k views

How to rename multiple files in a directory at the same time

I have directory say /var/tmp/abc which has 4 files: 12345-ram-3e3r5-io9490-89adu9.csv 45434-dam-qwe35-to9490-43adu9.csv 11234-cam-yy3r5-ro9490-85adu9.csv 14423-sam-hh3r5-uo9490-869du9.csv I want to ...
2
votes
1answer
235 views

How to modify this `while read; mv printf` code to rename only files of certain filetype?

Code in question: ls | cat -n | while read n f; do mv "$f" `printf "video_%03d.mp4" $n`; done The above code will rename all files/folders within the directory executed to: video_001.mp4 video_002....
0
votes
0answers
24 views

Renaming multiple files in specific order

I am looking to rename the 137 .jpg files from a directory with numbers from 1 to 137 keep the same order. The files look like this: IMG_20190512_164221.jpg IMG_20190512_171322.jpg ...
67
votes
6answers
35k views

Flattening a nested directory

This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1): /dir1 /dir2 | --- file1 | --- file2 What is ...
1
vote
2answers
281 views

wget download files from a file list, how to specify names for each of the downloaded file?

When downloading a single file, we can use wget's -O option to specify the file name. When I'm downloading Urls in a file using wget -i filelist.txt (filelist.txt contains list Of Urls I want to ...
3
votes
1answer
54 views

Find files then move them and rename them at the same time?

Currently I use three steps to gzip some static assets and then use s3cmd to an S3 bucket (technically it's a Digital Ocean Spaces bucket). Here's what I do: $ find . -type f -name '*.css' | xargs -I{...
0
votes
1answer
49 views

Can't remove commas in filenames on Linux

I have folder named 'data' in the terminal folder. Some of the file names in data have a ',' in them. I am able to list them by $ cd data $ ls -i |grep -E '\,' But I don't know how to remove ',' ...
1
vote
1answer
32 views

how to rename a number of files using wildcard as prefix

Assume I have many files names something like: foo_192.168.1.1.sh bar_192.168.1.1.sh baz_192.168.1.1.sh qux_192.168.1.1.sh and I want to rename them all to foo_192.168.1.100.sh bar_192.168.1.100....
6
votes
5answers
1k views

How to shift filename numbers without collisions?

Consider this list of files: $ touch index-{1,2,3,4,5,6,7,8,9}.txt If I want to shift them down so they start at zero, it's relatively easy: $ rename --verbose 's/^index-([1-9])\.txt$/$1/; $_="...
10
votes
4answers
2k views

What's the difference between 'rename' and 'mv'?

It's not completely clear to me, but what is the difference between mv and rename (from util-linux-ng 2.17.2 as /usr/bin/rename)? Are there advantages of one over the other beyond rename accepting ...
0
votes
1answer
60 views

How to rename a file with different name? [closed]

I have a file named servername_test_LINUX_test_test_2019-04-19.xls I have to create multiple copies of this file, with the condition that server name should be changed in each file created e.g. ...
0
votes
4answers
215 views

Bash multiple rename in one line: is possible?

Is possible to rename and substitute on fly with bash? for example i have VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB I want to rename for use in mencoder with movie_1.avi movie_2.avi,etc.. I know ...
5
votes
3answers
2k views

Remove characters from file names recursively

I have hundreds of directories, some nested in other directories, with tens of thousands of files. The files need to have a date/time stamp removed from them. An example filename is Letter to Client ...
5
votes
1answer
146 views

Rename files to change punctuation and numbering

I need a command to recursively rename a large number of jpg files in Ubuntu. However there are some problems. A normal group of files would look like ani-estate-villas_1431640729_3.jpg, ani-estate-...
142
votes
11answers
176k views

Merging folders with mv?

If I use mv to move a folder called "folder" to a directory that already contains "folder" will they merge or will it be replaced?
0
votes
2answers
75 views

Batch rename media files

I have an Enigma2 FreeSat recorder that I've now hooked up to my Plex Media Server. Plex can see and play the files from the Enigma2 just fine, but the file naming makes this unattractive. How can I ...
2
votes
1answer
61 views

Changing file names based on enclosing directory

Excuse the newby question but I have a number of unique directories which each contain a single file of a generic name. What I would like to do is to move nd rename the files into a single directory ...
22
votes
9answers
30k views

Preserve directory structure when moving files using find

I have created the following script that move old days files as defined from source directory to destination directory. It is working perfectly. #!/bin/bash echo "Enter Your Source Directory" read ...
0
votes
1answer
56 views

Does changing Linux username give any problems?

I've installed Linux Mint on my old laptop. I created a username with the temporary use in mind so it is not that good name and I want to change it. I know how to change username and rename the ...
0
votes
2answers
98 views

How to rename multiple files into one name [duplicate]

I would like to rename these files; 2000.jpg B001.jpg 9002.jpg D006.jpg to these names below ICON000.jpg ICON001.jpg ICON002.jpg ICON006.jpg respectively.
1
vote
2answers
56 views

Want to rename a files in folder with folder_1.txt folder_2.txt folder_n.txt name

I have 3 directories on my Ubuntu machine, named abc, xyz and pst. In each directory, I have approximately 7 files with different names. I want to rename each file like abc_1.txt, abc_2.txt, abc_3.txt,...
0
votes
1answer
25 views

Copy and rename files to a sequential numbering with subdirectories

I want to copy files of the given type with inside subdirectories. I think copy of the zzz.txt file works after copying the files in the abc_folder. How can i resolve this problem. AAA ---aaa.txt ...
1
vote
2answers
5k views

Add text to end of the filename but before extension

I have several mp3's that i need to add '_p192' before the extension. I've tried this : for f in *.mp3; do printf '%s\n' "${f%.mp3}_p192.mp3"; done following this post: adding text to filename ...
0
votes
1answer
26 views

Copy only files with certain extension while renaming each file according to the parent folder

I have several directories: ├── folder1.x │   ├── dsferwe │   ├── ewrwr342 │   ├── analysis │   ├── fdsds │   ├── vcxvcxz │   ├── 324322 │   ├── export.asc │   ├── f_random_subfolder.xf │   │   ├── -....
156
votes
12answers
260k views

How do I change the extension of multiple files?

I would like to change a file extension from *.txt to *.text. I tried using the basename command, but I'm having trouble on changing more than one file. Here's my code: files=`ls -1 *.txt` for x in ...
0
votes
3answers
62 views

In a bash shell script, how to rename multiple files, keeping only the numbers and the extension of the original file names?

I have a directory with a bunch of files with names like this: generic name- dd -01 _.txt generic name- dd -02 _.txt generic name- dd -03 _.txt generic name- dd -04 _.txt And I want to rename all of ...
0
votes
1answer
46 views

Swap words and reformat date in a filename

I have several recordings with a file-name schema like this %year%month%day-%hour%minute%second__%phonenumber.amr e.g.: 20190212-112007__+313206601234.amr I want to swap words to obtain: %...
0
votes
1answer
37 views

batch rename files in Ubuntu: sequential numbering, based on order in directory. (Ubuntu 16.04)

I had to download videos from DVR in more trials. After that files were manually arranged by alphabetical order into few groups, in each group by numbers. It is necessary to have videos in former ...