Question

We have been having some issues where people have been putting files into the folder for the wrong job number. files for 664585_custnum_qty_filetype.dat should be in folder 664585 I am looking for a way to make sure that the files in a given folder all start with the foldername. I have been working with.

@ECHO OFF
FOR /R "V:\Work" %%G in (.) DO (
 Pushd %%G
 REM Echo now in %%G
 for %%a in (.) do set currentfolder=%%~na
    echo %currentfolder%
    REM this is where I would be finding files that dont start the right way.
 Popd )
 Echo "back home"
Pause

trying to combine two other things that I have seen for iterating through folders and finding current directory name

Ultimately I want to list all the files that are out of place so that I can find them and figure out why they're not/who put them there. So I would like to have a program that iterated through all of the folders in V:\work into folders like 665485 and 332185 CustName displaying any files which do not start with 665485 or 332185 respectively.

I do have cygwin on my system, though not enabled all the time, and was considering ls, referencing C:\cygwin\bin\ls.exe directly to avoid it throwing off the normal functionality of some MS commands with the same name.

Any suggestions on how to get my list of files that dont start with the number from the foldername?

Was it helpful?

Solution

@echo off
for /d %%i in (*) do (if "%%i" NEQ "xArchive" (for /f %%j in ("%%i") do (dir "%%i" /b|for /f %%k in ('find "%%j" /v') do @dir "%%k" /b /s|find "thumbs.db" /v /i|find "xArchive" /v /i))

put this in the directory that contains the numbered folders and run it there. I'll be back in a few hours If you need me to change it. ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top