Solved

Command Line Batch Delete

Posted on 2010-11-21
12
344 Views
Last Modified: 2012-05-10
Hello,

I transferred a folder from my Mac to my PC and noticed its almost 4 times the original size because it copied the files and added a . infront of them all, my question is would there be a way to made a batch file that will go through all the pidgin nested folders and delete any file starting with a . for example, instead of level.dat there will be an extra file called .level.dat

Thanks in Advance!
0
Comment
Question by:jaysonmeyer
12 Comments
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34184077
Try this:

DEL /S ".*"

~bp
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34184079
Do that from the top directory that has the pad files, and subfolders of bad files, in it.

~bp
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 34184105
here's a vb script which does that, replace the FOLDER_PATH const.

Const FOLDER_PATH = "c:\temp\file"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FOLDER_PATH)
For Each objFile In objFolder.Files
if Left(objFile.Name,1) = "." then
Set aFile = objFSO.GetFile(objFile.Path)
aFile.Delete
end if
Next

Open in new window

0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 23

Expert Comment

by:Danny Child
ID: 34184703
if there are duplicates of all files, why is it FOUR times bigger in the new copy?  Should be just double?  Just asking in case there's more duplication issues to worry about.  
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34185990
Following billprew you can use "DEL /S ".*" from your top folder, but you can also specify your top folder like this:

DEL /S "C:\Folder1\Folder2\.*"
0
 

Author Comment

by:jaysonmeyer
ID: 34196310
I tried running

DEL /S ".*"

with no luck, nothing was deleted, I can go into some nested folders and some of the extra items my Mac added are still there, but I can manually delete them. Normally I wouldn't mind deleting the extra files but there's 64 folders in the main folder and each of those folders has approximately 40 more folders.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34196504
If you do DIR /S ".*" do the files list?

~bp
0
 
LVL 19

Accepted Solution

by:
Thommy earned 500 total points
ID: 34196546
If have tried DEL /S ".*" and DEL /S "C:\Folder1\Folder2\.*"

Both solutions worked fine.

If you call DEL /S ".*", keep in mind that you have to call it from out of the top folder!!!!

Try DEL /S "C:\Folder1\Folder2\.*" and specify your top folder as a parameter for the DEL command (Replace C:\Folder1\Folder2\ with your specific top folder for the ".*" files)

If you do so, it doesn't matter from where you start it...


0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34196590
I think these files may have the "hidden" attribute set actually, so try either of these:

DEL /A:H /S ".*"

DEL /A:H /S "C:\Folder1\Folder2\.*"

~bp
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34388623
This is a tough one, based on the original question I believe either #34184077 or #34196590 are solutions to the original question.  But without confirmation from the poster we can not be 100% certain.

~bp
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34388628
I would also add that #34184105 should be a viable solution as well, and we have no info if the question prefers a BAT or VBS solution.

~bp
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question