我有一个包含库存行的.csv文件。为了打印库存标签,我需要根据库存中的物品数量(每行的最终值)复制每一行。例如:
Spiritual Key Ring,400000044194,7.95,12
Mini Scarves,400000044187,7.95,6
Football Cap,400000044170,7.95,3
我想知道我是否可以开发一个读取文件(tags.csv)的批处理脚本并对其进行更新,以便将每行复制适当的次数。基于上面输入的示例:
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Spiritual Key Ring,400000044194,7.95,12
Mini Scarves,400000044187,7.95,6
Mini Scarves,400000044187,7.95,6
Mini Scarves,400000044187,7.95,6
Mini Scarves,400000044187,7.95,6
Mini Scarves,400000044187,7.95,6
Mini Scarves,400000044187,7.95,6
Football Cap,400000044170,7.95,3
Football Cap,400000044170,7.95,3
Football Cap,400000044170,7.95,3
我已经在记事本中复制并粘贴了很长一段时间,但我想点击一个按钮。非常感谢您的帮助!
答案 0 :(得分:2)
基于您提供的输入示例的简单嵌套FOR命令。
@echo off
FOR /F "TOKENS=1-4 DELIMS=," %%G IN (tags.csv) DO (
FOR /L %%L IN (1,1,%%J) DO echo %%G,%%H,%%I,%%J
)
pause