Batch rename folders

无人久伴 提交于 2019-12-25 12:09:12

问题


I have about 2000 folders all named like this

dataul_-_ppfsefs

music_-_ppfsefs

fun [gghhhses]

pictures_-_ppfsefs

backup [gghhhses]

tempfiles_-_ppfsefs

trash_it_-_ppfsefs

There are two unwanted portion at the end of the name "_-_ppfsefs" and " [gghhhses]", How to I rename them to look like this

dataul

music

fun

pictures

backup

tempfiles

trash_it


Edit: I'm on Mac OSX (installed brew, macports).


回答1:


The following two commands should do it:

for dir in * ; do mv "${dir}" "${dir/_-_ppfsefs/}" ; done

for dir in * ; do mv "${dir}" "${dir/ [gghhhses]/}" ; done


来源:https://stackoverflow.com/questions/21475596/batch-rename-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!