Solved

Robocopy only files with no extension?

Posted on 2009-05-09
14
3,373 Views
Last Modified: 2012-08-14
I need to move only files with specified extensions from one drive to another while preserving tree structure.  No problem, I know how to do that with Robocopy.

But I also need to move only files that have no extension.  I can't figure out how to specify files with no extension.  I've tried every combination of include *. and exclude *.*  in the robocopy command line that I can think of, but haven't found a way to copy ONLY files with no extension.

This despite the fact that the command
dir *.
very nicely lists only files without extensions.

I'm trying to reduce the size of a data collection, presently at 600GB and 2.2 million files by moving out file types I don't need to index, because my indexing tool (x1) is grinding to a halt at about 1.2 million files.

If this can't be done with robocopy, I'd appreciate pointers to a utility which can.  I'd also be open to a utility which could rename all files without extensions from *. to *.noext and could do so all the way thru a huge directory tree.  

Thanks!

Frank
0
Comment
Question by:fdenman
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24346776
Found this (Untested)
Last post
https://www.computing.net/answers/unix/find-file-with-no-extension/2810.html
=============================
find mydir -type f ! -name "*.*"
=============================
This will find the files (Have not tested it)

If this works, you will just need to find a way to implement it into a move function.
I am not sure if Robocopy can do this.

Carrzkiss
0
 
LVL 1

Author Comment

by:fdenman
ID: 24346822
This looks like a unix command.  I don't see the -type switch available for the Windows find command.
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24346852
I cannot seem to find anything on it.
Sorry that I was unable to help more.

Carrzkiss
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 48

Assisted Solution

by:dbrunton
dbrunton earned 150 total points
ID: 24346882
Very interesting.  Just been playing with robocopy.  Yes it does not work as it should.

Try Ztree http://www.ztree.com/

You can see all of the files in a directory tree with this - not just the folder - and it will show all of the files that have no extension.  You can filter the files you want to see.  It does understand *.

You could use Ztree to do all of the copying for you - Ztree can take the folders across for you - or you could get it to mark the files with no extension with an extension such as zzzzzzzz.  Get robocopy to copy it across and then at the other end use Ztree to remove the zzzzzzz extension.
0
 
LVL 14

Accepted Solution

by:
BigBadWolf_000 earned 175 total points
ID: 24347059
The script below will process and rename files with no extensions to *.noext (in subdirectories as well)
Save in notepad as filename.bat
Change the D:\zzz to your root folder or drive
Once done you can use robocopy

@echo off
set SourceFolder=D:\zzz
for /f "delims=" %%a in ('dir /a:-d /b /s "%SourceFolder%\*."') do ren "%%a" "%%~na.noext"

Open in new window

0
 
LVL 1

Author Comment

by:fdenman
ID: 24347355
I think Drs. Brunton & Wolf have each offered an excellent solution.  I plan to split the points as soon as I can confirm that these work as expected.  I have left Dr Wolf's bat file running overnight on my tree with 2.2 million files.  I'm hoping it will be finished when I wake up.

Does anybody have a feel for the relative speed of ZTree versus Dr Wolf's bat file?

0
 
LVL 48

Expert Comment

by:dbrunton
ID: 24347389
That's hard to say.

Ztree can handle millions of files.  As the website says memory is the only problem.  Dr Wolf's solution can be set to run and walk away.  

With ZTree you'll have to wait until it loads all of the files and that may take time.  On my system it takes about 30 seconds to load 100,000 files.  Your system may differ.  There's a 30 day evaluation version to try out.  Once it's loaded it's easy enough to filter the files and apply.
0
 
LVL 4

Expert Comment

by:althakar
ID: 24347415
just give extension name to it.. transfer the file and rename it back to previous one
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24347875
You can test for files without extensions using %%~x as in the following example (this merely displays the filenames on the screen):

for /f "tokens=*" %%a in ('dir /a-d /b *.*') do (
    if "%%~xa"=="" echo %%~na
)
0
 
LVL 16

Assisted Solution

by:t0t0
t0t0 earned 175 total points
ID: 24347879
if you want to give those files an extension say '.EXT. then you would do this in a batch file:

for /f "tokens=*" %%a in ('dir /a-d /b *.*') do (
    if "%%~xa"=="" ren "%%a" "%%~na.EXT"
)


Or to just move them:

for /f "tokens=*" %%a in ('dir /a-d /b *.*') do (
    if "%%~xa"=="" move "%%a" c:\windows\temp
)
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24347894
If you want to rename AND move them say, to '.EXT', then you need this:

for /f "tokens=*" %%a in ('dir /a-d /b *.*') do (
    if "%%~xa"=="" (
        ren "%%a" "%%~na.EXT"
        move "%%a.EXT" c:\windows\temp
    )
)


or you can do the whole thing in a single rename/move operation as in:

for /f "tokens=*" %%a in ('dir /a-d /b *.*') do (
    if "%%~xa"=="" (
        move /y "%%a" "c:\windows\temp\%%~na.EXT"
    )
)
0
 
LVL 1

Author Comment

by:fdenman
ID: 24348931
I think Drs. Brunton & Wolf have each offered an excellent solution.  I plan to split the points as soon as I can confirm that these work as expected.  I have left Dr Wolf's bat file running overnight on my tree with 2.2 million files.  I'm hoping it will be finished when I wake up.

Does anybody have a feel for the relative speed of ZTree versus Dr Wolf's bat file?

0
 
LVL 16

Expert Comment

by:t0t0
ID: 24348962
If all you want to do is rename ALL file in the current directory and ALL sub-directories then the following command will do the job.

    for /f "tokens=*" %a in ('dir /a-d /b /s *.*') do @if "%~xa"=="" @ren "%a" "%~na.noext"
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24348990
dbrunton

Nice to see ZTree get a mention.... I remember playing with XTree version 1.0 (Was written in French) when it first appeared.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to run a batch process 16 48
DOS Command to remove CR/LF to have one id and one text per line 13 57
Reading registry key from HKCU and not hklm 10 108
Bat File Script - HELP 2 15
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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