Ruby to rename files

前端 未结 2 739
不知归路
不知归路 2021-01-14 10:00

I have a script that renames files from a .csv file, this file works fine but am looking to edit it a little bit more so that it help me even more.

The scenario is I

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-14 10:58

    Here's a little tidbit for you. Maybe it will help out. http://rtdptech.com/2010/08/ruby-shell-script-to-rename-files-in-a-folder/

    I used something like this for a quickie because I wanted to use the rdoc/ri files to make little examples. I copied some directories to another location and the wanted to change the extension from *.ri to *.rb so I could put my runnable ruby code in.

    here's the command line version

    $ ruby -e "Dir.glob('*/*.ri').each {|i| File.rename(i, i.gsub('ri', 'rb'))}"
    

    and here is file version

    Dir.glob('*/*.ri').each {|i| File.rename(i, i.gsub('ri', 'rb'))}
    

提交回复
热议问题