Removing data/making empty - the list of files in a folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#16 Post by vsmeruga » 07 Jul 2014 09:37

Thanks Squashman. I will try copy command.

Antonio : I have to make the file empty every morning before the process starts.

vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#17 Post by vsmeruga » 07 Jul 2014 09:56

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

vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#18 Post by vsmeruga » 07 Jul 2014 09:57

Listed 12 files in 12 rows(Col A) and named the file as EmptySheet.xlsx

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Removing data/making empty - the list of files in a fold

#19 Post by Squashman » 07 Jul 2014 10:27

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.

vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#20 Post by vsmeruga » 08 Jul 2014 02:26

Okay I will try with empty excel sheet.

Thanks
VJ

vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#21 Post by vsmeruga » 08 Jul 2014 02:48

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Removing data/making empty - the list of files in a fold

#22 Post by foxidrive » 08 Jul 2014 03:03

Try this:

Code: Select all

@echo off
for %%a in (*.xlsx) do copy "F:\test\EmptySheet.xlsx" "%%a" /Y
pause

vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#23 Post by vsmeruga » 08 Jul 2014 03:39

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.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Removing data/making empty - the list of files in a fold

#24 Post by Squashman » 08 Jul 2014 06:55

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.

vsmeruga
Posts: 35
Joined: 04 Jun 2014 06:42

Re: Removing data/making empty - the list of files in a fold

#25 Post by vsmeruga » 08 Jul 2014 08:51

Thanks Squashman.

Post Reply