2017-01-05 101 views
0

我嘗試「自動」將我的csv文件的名稱的一部分(名爲
(例如)'Trendreporting - 10.csv'重命名爲'Trendreporting.csv')通過批處理文件的特定文件 爲了更清楚,我想改變這一點:通過批處理文件自動重命名csv文件

Trendreporting - 10.csv (the part behind the - is variable: (so e.g. also Trendreporting - 07.csv) but there´s always only 1 csv file in the folder at a time) 

要這樣:

Trendreporting.csv 

我這個查詢嘗試它已經:

@echo off 
setlocal enableDelayedExpansion 
for %%A in (TrendReporting - *.csv) do (
    set "name=%%A" 
    ren TrendReporting - *.csv ** 
) 

但什麼也沒有發生,當我執行文件 - 哪裏出錯?

回答

1
@echo off 
setlocal 
ren "TrendReporting - *.csv" "Trendreporting.csv" 

包含空格的名稱必須用引號括起來,否則可選。

你不需要delayedexpansion,也不是for,你也不需要無謂設置name

+0

工作得很好 - 非常感謝! – AbsoluteBeginner