重命名文件夹和Windows系统中的文件递归

发布于 2024-12-15 08:20:51 字数 859 浏览 0 评论 0原文

我有以下文件夹结构:

Top Folder
    -> SubFolder1
        -> MyFolder_Latest
        -> MyFile_Latest.txt
    -> SubFolder2
        -> MyFolder_Latest
        -> MyFile_Latest.txt
    -> SubFolder3
        -> MyFolder_Latest
        -> MyFile_Latest.txt

我希望更改上面给出的不同子文件夹中的文件夹和文件。所有文件夹和文件都具有相同的名称,我希望更改为以下名称:

Top Folder
    -> SubFolder1
        -> myfolder
        -> myfile.txt
    -> SubFolder2
        -> myfolder
        -> myfile.txt
    -> SubFolder3
        -> myfolder
        -> myfile.txt

基本上在这里做两件事: a) 从所有文件和文件夹名称中删除 _Latest。 b) 将所有文件夹和文件的大小写更改为小写

有人知道如何在 Windows 中实现上述目标吗?我的系统不允许安装 UNIX,并且我无法将这些文件复制到 UNIX 系统,因为我们的网络当前不提供任何 UNIX 机器上的 SCP 或 FTP 权限:-(

另外,如果有人在 UNIX 中有合适的解决方案,我可以尝试将文件夹复制到 DVD 并尝试在 UNIX 机器上运行命令:-)

I have the following folder structure:

Top Folder
    -> SubFolder1
        -> MyFolder_Latest
        -> MyFile_Latest.txt
    -> SubFolder2
        -> MyFolder_Latest
        -> MyFile_Latest.txt
    -> SubFolder3
        -> MyFolder_Latest
        -> MyFile_Latest.txt

I wish to change the folders and files in the different SubFolders, given above. All the folders and files have the same name, and I wish to change to the following:

Top Folder
    -> SubFolder1
        -> myfolder
        -> myfile.txt
    -> SubFolder2
        -> myfolder
        -> myfile.txt
    -> SubFolder3
        -> myfolder
        -> myfile.txt

Basically doing two things here:
a) Removing the _Latest from all the file and folder names.
b) Chnaging the case of all the folders and files to lower case

Anybody has any idea on how to achieve the above in Windows? My system does not allow installation of UNIX and I cannot copy those files to a UNIX system, as our network currently does not provide SCP or FTP permissions on any of the UNIX boxes :-(

Also, if someone has a suitable solution in UNIX, I can try copying the folders to a DVD and trying to run the commands on a UNIX box :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思碎 2024-12-22 08:20:51

显示的文件夹结构不需要递归。只需循环遍历结构第一层中的所有文件夹并适当地重命名它们即可。

请参阅 HELP FOR

并尝试在仔细测试后开始使用

@echo off
set TopFolder="c:\temp\Top Folder"
pushd %TopFolder%
for /d %%a in (*.*) do (
  if exist "%%~fa\MyFolder_Latest" echo REN "%%~fa\MyFolder_Latest" myfolder
  if exist "%%~fa\MyFile_Latest.txt" echo REN "%%~fa\MyFile_Latest.txt" myfile.txt
)
popd

,删除 ECHO 命令。

The folder structure shown does not require recursivity. Just loop through all the folders in the first level of the structure and rename them appropriately.

See HELP FOR

and try this to get you started

@echo off
set TopFolder="c:\temp\Top Folder"
pushd %TopFolder%
for /d %%a in (*.*) do (
  if exist "%%~fa\MyFolder_Latest" echo REN "%%~fa\MyFolder_Latest" myfolder
  if exist "%%~fa\MyFile_Latest.txt" echo REN "%%~fa\MyFile_Latest.txt" myfile.txt
)
popd

after careful testing, remove the ECHO command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文