Comments on: The Ultimate Guide to Handling Filenames with Special Characters in Linux https://www.tecmint.com/special-character-filenames-linux/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Fri, 27 Sep 2024 06:10:20 +0000 hourly 1 By: Ravi Saive https://www.tecmint.com/special-character-filenames-linux/comment-page-1/#comment-2220950 Fri, 27 Sep 2024 06:10:20 +0000 http://www.tecmint.com/?p=13997#comment-2220950 In reply to eddie.

@Eddie,

You can use a bash script to convert the files while preserving their names with spaces.

#!/bin/bash

for file in *.mp4; do
    # Remove the file extension and create a new name with .mp3
    new_file="${file%.mp4}.mp3"
    
    # Use your conversion command here (e.g., ffmpeg)
    ffmpeg -i "$file" "$new_file"
done

Make sure to run this script in the directory containing your files, and it will convert all .mp4 files to .mp3 while keeping the original names intact.

]]>
By: eddie https://www.tecmint.com/special-character-filenames-linux/comment-page-1/#comment-2214093 Thu, 12 Sep 2024 15:25:46 +0000 http://www.tecmint.com/?p=13997#comment-2214093 I have 22 files with long names, including several spaces in each name. I want to convert the files using a bash script while preserving the names, e.g., convert ‘now only dance with me.mp4‘ to ‘now only dance with me.mp3.’

Converting the file is not the problem; it’s how to preserve the original name, including the spaces. Is it even possible using a bash script?

]]>
By: Vijay Prakash Sharma https://www.tecmint.com/special-character-filenames-linux/comment-page-1/#comment-1822698 Fri, 10 Jun 2022 15:53:53 +0000 http://www.tecmint.com/?p=13997#comment-1822698 In reply to inukaze.

You can use a single quote with any character to copy and move anywhere like this. The file name does not matter whether it is long or short, USE a single quote

[root@ip-172-31-2-191 test]# touch '[!](EJU)#_()'
[root@ip-172-31-2-191 test]# ls -l
-rw-r--r-- 1 root root 0 Jun 10 15:51 [!](EJU)#_()
[root@ip-172-31-2-191 test]# mv '[!](EJU)#_()' /root
[root@ip-172-31-2-191 test]# ls -l /root
total 0
-rw-r--r-- 1 root root  0 Jun 10 15:51 [!](EJU)#_()
]]>
By: Vijay Prakash Sharma https://www.tecmint.com/special-character-filenames-linux/comment-page-1/#comment-1822693 Fri, 10 Jun 2022 15:36:51 +0000 http://www.tecmint.com/?p=13997#comment-1822693 In reply to santosh.

mv “File Name with Space” “Full Path of file name”

]]>
By: santosh https://www.tecmint.com/special-character-filenames-linux/comment-page-1/#comment-1652906 Thu, 18 Nov 2021 05:23:37 +0000 http://www.tecmint.com/?p=13997#comment-1652906 How can I move files from one place to another if it contains spaces using a shell?

]]>