Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Renaming files based on Folder Names

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
Fluke667
Posts: 4
Joined: 2018-10-14 11:04

Renaming files based on Folder Names

#1 Post by Fluke667 »

I want Rename mp4 files in my Subfolders, the filename should be same as the folder Name after renaming...

This is my Command:

ls */*.mp4 | awk -F'/' '{print "mv " $0 " ./" $1 "_" $2 }' | bash


FolderA/MovieA.mp4 >>> FolderA.mp4
FolderB/MovieB.mp4 >>> FolderB.mp4
FolderC/MovieC.mp4 >>> FolderC.mp4



But it does not work if the folder or filesnames got a Bracket or Space or other special chars, what can i do?

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Renaming files based on Folder Names

#2 Post by debiman »

bash:

Code: Select all

for i in *.mp4; do
    mv "$i" "${PWD##*/}_$i"
done
(not tested. needs to be run inside the folder containign the videos)

Post Reply