Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
除了一个子文件夹之外,清除文件夹内容的最佳方法是什么?
例子:
输入:
Folder_A | Folder_B | DoNotDeleteMe | Folder_C | Some_File
结果:
Folder_A | DoNotDeleteMe
是否有任何 FileUtils 命令可以帮助我解决这个问题?通配符?
我去了:
Dir.foreach(myPath) do |item| next if item == '.' or item == '..' or item == mySubDir FileUtils.rm_rf File.join(myPath, item) end