0

I want to rename files with a .m4a extension recursively in child directories to remove unwanted characters in audio files such as [ ' ].

That's because that this below happened to this file 04 Tears Don't Fall.m4a without the other files:

Could not load file 2005-09-30 - The Poison (Deluxe Edition) [US - 88697-09021-2 - 2007]/04 Tears Don't Fall.m4a. Maybe it is not a supported file format? When trying to load using ffmpeg, got the following error: FFmpeg could not read the file.

1
  • After renaming, It still throws the same error. Maybe A corrupted track. Aug 18 at 3:07

3 Answers 3

4

There must be some other issue at work, because ffmpeg is perfectly able to read filenames containing single quotes:

mkdir '2005-09-30 - The Poison (Deluxe Edition) [US - 88697-09021-2 - 2007]'
cp -p {another.m4a} "2005-09-30 - The Poison (Deluxe Edition) [US - 88697-09021-2 - 2007]/04 Tears Don't Fall.m4a"

ffmpeg -i "2005-09-30 - The Poison (Deluxe Edition) [US - 88697-09021-2 - 2007]/04 Tears Don't Fall.m4a"

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2005-09-30 - The Poison (Deluxe Edition) [US - 88697-09021-2 - 2007]/04 Tears Don't Fall.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 0
    compatible_brands: M4A mp42isom
...

Maybe you're not quoting properly. Unfortunately without seeing your code it's not possible to verify this, only flag it as a possible issue.

However, if you really want to rename the files to remove a set of characters, you can use code like this:

find . -type f -name '*.m4a' -exec \
    sh -c 'for f in "$@"; do echo mv "$f" "${f'"//[\']/"'}"; done' _ {} +

Remove echo when you are ready to execute the mv.

The [\'] range can be extended to include additional characters that are to be removed. For example, you might choose [\'\\\"\\\`:] to remove single and double quotes, backticks, and colons. (Single quotes must be prefixed with \ ; double quotes, backticks, and dollar symbols must be prefixed with \\\.)

2
  • FFmpeg was being used in demucs python module, so there is no way to quote it as far as I know. Aug 18 at 2:48
  • After renaming, It still throws the same error. Maybe A corrupted track. Aug 18 at 3:06
2
#!/bin/bash

shopt -s globstar
for fn in **/*\'*.m4a; do echo mv "$fn" "${fn/\'/}"; done

echo is needed for checking the result before real renaming.

1
2

First of all we write a shell script that move $1 to $1 without (') and we call it special_move.sh. Do not forget to give the file execution permission.

#!/bin/bash

orgFile=$1
destFile=${orgFile//\'/}

echo "mv $orgFile $destFile"
#mv $orgFile $destFile

Then move to root dir where files are stored and type cmd

find . -name "*'*.m4a" -exec /absolute/path/special_move.sh {} \;

It test is satisfying, uncomment last row of script file.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.