All Questions
Tagged with shell-script rename
181 questions
463
votes
18
answers
702k
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 changing more than one file.
Here's my code:
files=`ls -1 *.txt`
for x in $...
2
votes
6
answers
655
views
Convert EPOCH string in filename to readable format
My knowledge of Unix is not very good.
I'm trying to write a shell script to rename a set of files in a directory, like 1709532255.mp4 to 20240304_070415.mp4, where 1709532255 is always an epoch time.
...
3
votes
3
answers
87
views
Rename batch of pictures with a very specific format
I have about 4k pictures with this format:
photo_6923@06-01-2022_14-18-36.jpg
photo_6924@07-01-2022_00-03-23.jpg
photo_6925@07-01-2022_01-36-20.jpg
photo_6926@07-01-2022_10-44-20.jpg
photo_6927@07-01-...
37
votes
14
answers
62k
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
1
answer
89
views
Need help with a script that mv (renames) filenames that require single quotes in ls output or file operations
I need help with a script that mv (renames) filenames that are shown with single quotes in ls output or files that require single quotes for file operations. The script will be used to rename all ...
4
votes
1
answer
1k
views
Replace all periods with hyphens recursively
To replace all spaces with hyphens, in all files/folders, in all sub-directories, I run the following:
find /path/to/folder -depth -name "* *" -execdir rename 's/ /-/g' "{}" \;
...
19
votes
9
answers
75k
views
How to rename all files with special characters and spaces in a directory?
How can I rename all the files in a specific directory where the files contains blanks spaces and special characters ($ and @) in their names?
I tried the rename command as follows to replace all the ...
0
votes
1
answer
160
views
Renaming batch files for PLEX
I am attempting to rename a batch of .mkv files from the original format to the preferred PLEX format. I am having difficulty with sed and with rename and with mv. I hope it is just a syntax error I ...
-2
votes
1
answer
272
views
Need to batch rename files with names from text file using core utils
So I am a bit of a noob and have a problem at work. There is a program outputs names in a ie
apple
banana
orange
P1n34ppl3
The problem is that the files that correspond to that (separate program) are ...
0
votes
2
answers
83
views
The loop for file renaming doesn't work right
There are 32 *.dds files in a folder:
pic-0.dds, pic-1.dds, pic-2.dds,...,pic-31.dds
I'd like to rename them to be:
015040.dds, 015041.dds, 015042.dds,...,0150471.dds.
I'm trying to use the ...
66
votes
3
answers
246k
views
How to rename multiple files in single command or script in Unix? [duplicate]
I have the below list of files
aro_tty-mIF-45875564pmo_opt
aro_tty-mIF-45875664pmo_opt
aro_tty-mIF-45875964pmo_opt
aro_tty-mIF-45875514pmo_opt
aro_tty-mIF-45875524pmo_opt
that I need to rename to
...
32
votes
4
answers
65k
views
How to replace spaces in all file names with underscore in Linux using shell script?
I tried following shell script which should replace spaces from all xml filenames
for xml_file in $(find $1 -name "* .xml" -type f);
do
echo "removing spaces from XML file:" $xml_file
mv "$xml_file"...
2
votes
2
answers
2k
views
Copying/Moving folders where destination folder already exists
I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged.
I am attempting to use a solution from this ...
3
votes
2
answers
420
views
How might one except hidden '.' files and directories from a script that renames them?
I have a script that renames, getting rid off the whitespace, every directory and file. It does it recursively:
#!/bin/bash
find -name "* *" -print0 | sort -rz | \
while read -d $'\0' f; ...
2
votes
4
answers
1k
views
Rename a bunch of file by replacing a number in the filename by a coresponding string from a textfile
I have a large number of files I want to rename. Each filename contains a number (xxx): FIXED_PART_xxx_UNIQUE_PART.
I also have a text file, which has a number and a string in each line:
001 string001
...