zoukankan      html  css  js  c++  java
  • batch rename files

    batch rename files

    batch rename files

    Command Prompt

    You can use the rename – or ren – DOS command in a Command Prompt window to rename multiple files at once. It accepts the wildcard character – * – to match multiple files. The quickest way to open a Command Prompt window at your desired location is to hold Shift, right-click in the folder, and select “Open command window here.”

    The most obvious use case for the rename command is changing multiple file extensions at once – something you can’t do in Windows Explorer. The following command will rename all .html files in the current folder to .txt files:

    ren *.html *.txt
    

    This command doesn’t offer a lot of power on its own, although it can be integrated into more complex batch scripts.

    PowerShell

    PowerShell offers much more flexibility for renaming files in a command-line environment. Using PowerShell, you can pipe the output of one command – known as a “commandlet” in PowerShell terms — to another command, just like you can on Linux and other UNIX-like systems.

    The two important commands you’ll need are Dir, which lists the files in the current directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir to Rename-Item and you’re in business.

    After you launch PowerShell, use the cd command to enter the directory containing your files. You should put the files in their own directory so you don’t accidentally rename other files.

    Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }
    

    Replace the “ “ and “ parts of the command to replace other characters in file names.


    Post by: Jalen Wang (转载请注明出处)

  • 相关阅读:
    Linux下的crontab定时执行任务命令详解
    TP5使用Composer安装PhpSpreadsheet类库实现导入导出
    在本地创建分支并发布到远程仓库
    Linux中文件的可读,可写,可执行权限的解读以及chmod,chown,chgrp命令的用法
    crontab 定时写法整理
    Linux && Windows下基于ThinkPHP5框架实现定时任务(TP5定时任务)-结合Crontab任务
    Echarts环形图、折线图通过ajax动态获取数据
    javascript另类方法高效实现htmlencode()与htmldecode()函数,附带PHP请求完整操作
    PHP获取本月开始、结束时间,近七天所有时间
    关于sql中case when用法
  • 原文地址:https://www.cnblogs.com/jalenwang/p/2943083.html
Copyright © 2011-2022 走看看