Here is the equivalent bash
script that I am trying to convert to fish
:
for j in *.md; do mv -v -- "$j" "${j%.md}.txt"; done
Here is what I tried:
for file in *.md
mv -v -- "$file" "{{$file}%.md}.txt"
end
But it simply ends up renaming all of the files like so:
‘amazon.md’ -> ‘{{amazon.md}%.md}.txt’
How do I do this correctly?
How to batch rename extensions. Navigate to the folder containing the files you want. Once there, launch command prompt from the folder menu by holding down shift and right clicking on an empty space. Once in command prompt, you can now use the ren (for rename) command to rename for example, .
Sometimes you might want to rename the extension of your file and this can be quickly done using rename() method in Python. This can be done by selecting the file and then getting only the file name using the splitext() method of the os module. This method returns the root and extension separately.
Extensions are part of a file's name. And if you want to change the extension (or the name), you'd use the mv command. mv stands for "move" and is the standard command on Linux for moving and renaming files.
To do this just with fish:
for j in *.md
mv -v -- $j (string replace -r '\.md$' .txt $j)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With