批量遍历子文件夹并重命名文件
我想遍历一个文件夹及其所有子文件夹,保留当前文件的计数器变量并将其重命名为 $counter$ExistingFileName。
例如,
$count = 1;
foreach $file in $folder
{
$file.name = $count + $file.name;
$count++;
}
能回答这个问题的人将是我的英雄! :)
顺便说一句,我使用的是 Windows 7。
I would like to traverse a folder and all it's subfolders, keep a counter variable of the current file and rename it to $counter$ExistingFileName.
E.g.
$count = 1;
foreach $file in $folder
{
$file.name = $count + $file.name;
$count++;
}
The person who can answer this will be my hero! :)
Btw I am using Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,当您在我对您的帖子的评论中思考我的问题时(或者可能仍在返回此网站阅读它们)时,这是我的试用镜头:
这将通过简单地在文件名前加上数字来重命名您的文件,像这样:
如果您愿意,可以这样:
为此,您需要对上述脚本进行两处更改(以粗体突出显示):
All right, while you are pondering over my questions in my comment to your post (or maybe still making your way back to this site to read them), here's my trial shot:
This will rename your files by simply prepending their names with numbers, like this:
If you like, you can have it this way:
For that you'll need to make two changes to the above script (highlighted in bold):