Removing data/making empty - the list of files in a folder
Moderator: DosItHelp
Re: Removing data/making empty - the list of files in a fold
Thanks Squashman. I will try copy command.
Antonio : I have to make the file empty every morning before the process starts.
Antonio : I have to make the file empty every morning before the process starts.
Re: Removing data/making empty - the list of files in a fold
Hi I tried below code but not successful. Please correct me.
Code: Select all
@setlocal enabledelayedexpansion
pushd \\filepath\ARec
for %%a in (*.xlsx) do copy \\filepath\ARec\EmptySheet.xlsx "%%a" /Y
Re: Removing data/making empty - the list of files in a fold
Listed 12 files in 12 rows(Col A) and named the file as EmptySheet.xlsx
Re: Removing data/making empty - the list of files in a fold
vsmeruga wrote:Listed 12 files in 12 rows(Col A) and named the file as EmptySheet.xlsx
EmptySheet is a blank excel document to overwrite the files it finds in \\filepath\ARec
You don't list the files you want to overwrite in the EmptySheet excel file.
Re: Removing data/making empty - the list of files in a fold
Okay I will try with empty excel sheet.
Thanks
VJ
Thanks
VJ
Re: Removing data/making empty - the list of files in a fold
Hi
1.) I have created empty xlsx file named(EmptySheet.xlsx ) and placed in F:\test folder.
2.) And all my 12 .xlsx files which has to be emptied are placed in the same folder.
3.) the batch script also placed in the same folder and it has below code
When I run it nothing happens. Please assist on this where I am wrong?.
Thanks
VJ
Code: Select all
@setlocal enabledelayedexpansion
pushd F:\test
REM for /f %%a in ('dir /b *.xlsx') do type nul >"%%a"
for %%a in (*.xlsx) do copy F:\test\EmptySheet.xlsx "%%a" /Y
Re: Removing data/making empty - the list of files in a fold
Try this:
Code: Select all
@echo off
for %%a in (*.xlsx) do copy "F:\test\EmptySheet.xlsx" "%%a" /Y
pause
Re: Removing data/making empty - the list of files in a fold
This modified code worked. But the filesize is showing as 8 KB(not 0 KB). When I open each file, Column A is selected in sheet1.
Re: Removing data/making empty - the list of files in a fold
vsmeruga wrote:This modified code worked. But the filesize is showing as 8 KB(not 0 KB). When I open each file, Column A is selected in sheet1.
Yep. By Default a new empty document is that size. Try it yourself. Just right click and use the context menu to create a new excel document.
Re: Removing data/making empty - the list of files in a fold
Thanks Squashman.