我有一个名为file.txt的文件,其中包含几行
1.vishnu 2.ram 3.gopal 4.suresh 5.chandra sekar 6.prem kumar 7.nandhu我编写了一个批处理脚本来读取每一行并创建一个文件夹并将这些行指定为该文件夹的名称。
FOR /f "tokens=* delims=" %a in (file.txt) DO @md %a但是,创建的文件夹为
vishnu ram gopal suresh chandra sekar prem kumar nandhu这里的chandra和sekar被分隔为两个文件夹,但我想将chandra sekar作为单个文件夹名称,如何实现这一点?
I have a file called file.txt in which it contains few lines as
1.vishnu 2.ram 3.gopal 4.suresh 5.chandra sekar 6.prem kumar 7.nandhuI have written a batch script to read each line and to create a folder and assign the lines as name to that folder.
FOR /f "tokens=* delims=" %a in (file.txt) DO @md %abut, the folder created as
vishnu ram gopal suresh chandra sekar prem kumar nandhuHere the chandra and sekar are seperated as two folders, but i want the chandra sekar as a single folder name, how to acheive this?
最满意答案
尝试这个:
FOR /F "tokens=2 delims=." %%A IN (file.txt) DO @md "%%A"说明: FOR -loop变量使用双倍百分比%% 。 此外,您需要将%%A中包含的文件名括在双引号中,以便将其解释为单个目录名,即使它包含空格。 最后,如果使用"tokens=* delims=" ,则创建的目录名称也将包含前导编号,即1.vishnu , 2.ram等。
Try this:
FOR /F "tokens=2 delims=." %%A IN (file.txt) DO @md "%%A"Explanation: FOR-loop variables use a double-percent %%. Also, you need to enclose the filename contained in %%A in double quotes, so that it is interpreted as a single directory name, even if it contains spaces. Finally, if you use "tokens=* delims=", the directory names that are created will contain the leading numbering as well, i.e. 1.vishnu, 2.ram and so on.
更多推荐
发布评论