我是新來的批處理腳本,我正在嘗試新的東西。如何使用批處理腳本將內容添加到具有各種路徑的文本文件中?
我有一個文件sample.txt
。它具有不同的路徑,如下所示:
C:\Users\admin\Desktop\Sample\New Text Document1.txt
C:\Users\admin\Desktop\Sample\New Text Document2.txt
C:\Users\admin\Desktop\Sample\New Text Document3.txt
C:\Users\admin\Desktop\Sample\New Text Document4.txt
我想在文件名之前在此路徑中添加文本。
我想要的文件看起來像這樣:
C:\Users\admin\Desktop\Sample\Backup Folder\New Text Document1.txt
C:\Users\admin\Desktop\Sample\Backup Folder\New Text Document2.txt
C:\Users\admin\Desktop\Sample\Backup Folder\New Text Document3.txt
C:\Users\admin\Desktop\Sample\Backup Folder\New Text Document4.txt
您將使用'FOR'命令,並使用命令修飾符分裂除了文件路徑文件名。你可以通過打開cmd提示符並輸入:FOR /?'來閱讀它。閱讀關於修飾符的最後一節。 – Squashman
我認爲它可能看起來像這樣 - FOR/F「delims = /」%% A IN(Sample.txt)Do(@echo +「BackUp Folder /」+ * .txt)但它需要更多 –
否不要使用'DELIMS'選項。使用修飾符。 '%〜dpA'和'%〜nxA'。 delims選項應該是空的。 'FOR/F「DELIMS =」' – Squashman