This is similar to GPRename but not as sophisticated. You can rename all
of the files in the current folder. Note: it is case sensitive (if you
need this function) so you can switch cases on files, IE rename
"Buster.txt" as "buster.txt"
#!/bin/bash
# Check if zenity is installed
if ! command -v zenity &> /dev/null; then
echo "Zenity is required but not installed. Please install it using 'sudo apt-get install zenity' or equivalent."
exit 1
fi
# Get search string from user
search_string=$(zenity --entry \
--title="Search String" \
--text="Enter characters to search for:" \
--width=300)
# Check if user cancelled
if [ $? -ne 0 ]; then
exit 0
fi
# Check if search string is empty
if [ -z "$search_string" ]; then
zenity --error --text="Search string cannot be empty!" --width=200
exit 1
fi
# Get replace string from user
replace_string=$(zenity --entry \
--title="Replace String" \
--text="Enter characters to replace with:" \
--width=300)
# Check if user cancelled
if [ $? -ne 0 ]; then
exit 0
fi
# Count files that will be renamed
count=0
for file in *; do
if [[ "$file" == *"$search_string"* ]]; then
((count++))
fi
done
# If no files match, inform user and exit
if [ $count -eq 0 ]; then
zenity --info --text="No files found containing '$search_string'." --width=200
exit 0
fi
# Perform rename operation
for file in *; do
if [[ "$file" == *"$search_string"* ]]; then
new_name="${file//$search_string/$replace_string}"
if [ "$file" != "$new_name" ]; then
mv -n "$file" "$new_name"
if [ $? -eq 0 ]; then
echo "Renamed: $file -> $new_name"
else
zenity --error --text="Error renaming $file to
$new_name" --width=200
fi
fi
fi
done
# Show completion message
zenity --info --text="Renaming complete. $count file(s) processed." --width=200
Interesting examples of what can be done in bash, but why?
I mean gprename or bulky are usually always available and have so many
more uses.
or is there a way to make gprename open in the current folder?Yes there is a way
On Wed, 17 Sep 2025 13:04:16 -0300
"Dr. Noah Bodie" <[email protected]> wrote:
or is there a way to make gprename open in the current folder?Yes there is a way
From Nemo open folder you want in terminal and type gprename and it
opens gprename in that folder. Or you mind something else.
This is similar to GPRename but not as sophisticated. You can rename all of the files in the current folder. Note: it is case sensitive (if you need this function) so you can switch cases on files, IE rename "Buster.txt" as "buster.txt"
#!/bin/bash
...
# Perform rename operation
for file in *; do
��� if [[ "$file" == *"$search_string"* ]]; then
������� new_name="${file//$search_string/$replace_string}"
������� if [ "$file" != "$new_name" ]; then
����������� mv -n "$file" "$new_name"
����������� if [ $? -eq 0 ]; then
��������������� echo "Renamed: $file -> $new_name"
����������� else
��������������� zenity --error --text="Error renaming $file to $new_name" --width=200
����������� fi
������� fi
��� fi
done
"Dr. Noah Bodie" <[email protected]> wrote:
or is there a way to make gprename open in the current folder?
Yes there is a way
From Nemo open folder you want in terminal and type gprename and it
opens gprename in that folder. Or you mind something else.
what i would like to do is find a way to make this script open in the current folder just by clicking a link, but i doubt that Linux has an
option that permits that function.
Interesting examples of what can be done in bash, but why?
I mean gprename or bulky are usually always available and have so many
more uses.
On 2025-09-17 10:08 AM, Alan K. wrote:It has issues with some . folders too. It has it quirks.
Interesting examples of what can be done in bash, but why?
I mean gprename or bulky are usually always available and have so many
more uses.
Well, I just discovered that GPRENAME will NOT work on my external HDD,
seems it can't even detect it. I needed to rename over a dozen files and
this script did the job while GPRENAME could not.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,070 |
Nodes: | 10 (0 / 10) |
Uptime: | 17:54:22 |
Calls: | 13,739 |
Calls today: | 1 |
Files: | 186,972 |
D/L today: |
2,323 files (721M bytes) |
Messages: | 2,420,078 |