Removing data/making empty - the list of files in a folder
Moderator: DosItHelp
Removing data/making empty - the list of files in a folder
Hi Gurus
I am looking for a windows command/procedure to remove the content (or) making the files empty - for a list of (.xls files only) in a folder.
Your help is much appreciated.
Many Thanks
VJ
I am looking for a windows command/procedure to remove the content (or) making the files empty - for a list of (.xls files only) in a folder.
Your help is much appreciated.
Many Thanks
VJ
Re: Removing data/making empty - the list of files in a fold
Run this in the folder with the xml files you want to destroy and it will make them into 0 byte files.
Code: Select all
@echo off
for %%a in (*.xml) do type nul >"%%a"
Re: Removing data/making empty - the list of files in a fold
Thanks I will try.
Re: Removing data/making empty - the list of files in a fold
I tried it locally on my machine and command worked. When I tried in shared folder, It is not working. It seems the existing .xls files has some security
Re: Removing data/making empty - the list of files in a fold
You need write permission to the files in the shared folder.
Be aware that the files can't be open in Excel or another program at the same time.
Be aware that the files can't be open in Excel or another program at the same time.
Re: Removing data/making empty - the list of files in a fold
Hi Foxidrive
I am struggling to achieve it.
Before removing data from the list of files, Can you help me with a command to set write permissions to all the files(.xls) in a folder?
Thanks
VJ
I am struggling to achieve it.
Before removing data from the list of files, Can you help me with a command to set write permissions to all the files(.xls) in a folder?
Thanks
VJ
Re: Removing data/making empty - the list of files in a fold
Your IT people can give you write permissions.
I don't know anything about the situation you are in.
I don't know anything about the situation you are in.
Re: Removing data/making empty - the list of files in a fold
sure thanks. I will talk to them
Re: Removing data/making empty - the list of files in a fold
Hi Foxidrive
I managed setting the path with the command pushd "path" and it worked. But when I double click to open the file I am getting the message as
"Excel cannot open the file 'Filename.xlsx' because the format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file"
script:
Code: Select all
@setlocal enabledelayedexpansion
pushd \\filepath\AutoRec
for /f %%a in ('dir /b *.xlsx') do type nul >"%%a"
Re: Removing data/making empty - the list of files in a fold
Hi
Do you have any other command to remove full content and saving the same file instead of outputting using (>)
Thanks
VJ
Do you have any other command to remove full content and saving the same file instead of outputting using (>)
Thanks
VJ
Re: Removing data/making empty - the list of files in a fold
I am using MS office 2010.
Re: Removing data/making empty - the list of files in a fold
So you are looking to remove the contents of a bunch of excel files but still have the excel file open with excel.
That would require some other scripting language like Vbscript or Jscript or even an excel VBA macro.
That would require some other scripting language like Vbscript or Jscript or even an excel VBA macro.
Re: Removing data/making empty - the list of files in a fold
Just create an empty Excel document in advance and copy it with the name of the files you want to delete:
Antonio
Code: Select all
@setlocal enabledelayedexpansion
pushd \\filepath\AutoRec
for %%a in (*.xlsx) do copy C:\thePath\EmptySheet.xlsx "%%a" /Y
Antonio
Re: Removing data/making empty - the list of files in a fold
Aacini wrote:Just create an empty Excel document in advance and copy it with the name of the files you want to delete:Code: Select all
@setlocal enabledelayedexpansion
pushd \\filepath\AutoRec
for %%a in (*.xlsx) do copy C:\thePath\EmptySheet.xlsx "%%a" /Y
Antonio
That would certainly keep it simple!
Re: Removing data/making empty - the list of files in a fold
Thanks. I managed this issue checking the size of the file. If filesize is Zero then do not process it.