| 1. |
Solve : Batch file for finding files on network shared drive? |
|
Answer» Hi, I'm new to the forums, but I would like to ask a question and hopefully get some help if I may; As expected, I am unable to install anything from that pageyou can download from home, and save to thumb drive. (you can bring all the .exe installed into 1 thumb drive). also, only if your laptop's usb drive is not locked down by you admin as well Another big fat zero... I can't believe how petty the admins actually are, I've tried 3 USB drives in my work machine, none of them are showing up, so I CALLED our IT Support and I'm told they locked the USB ports down for "security reasons" since your company has such as security policy, then there must be procedures when you need to use tools that are third party. Request permission from your boss to authorise the use of such tools (If its really for your work). Tell them these are tools that will increase your productivity. If its still a gone case, you will need to learn some DOS batching or vbscripting. Well, I did have a go at a batch file, but it's only slightly what I'd hoped for: echo off echo. DIR Z: /A :RSA -D /P sortorder -S pause (I have the network drive mapped to Z: in my drives list) This sort of works fine, but it lists the directories and then the files in no particular order, I'd prefer it not to list the directiories, but to interrogate them for large files and then print out a list of filenames starting with the largest file first. Quote from: icage on April 08, 2010, 07:42:50 AM
well to remove the directories try the following: DIR Z: /A -D /P sortorder -S for more information type DIR /? Quote find . -size +9999999c 2> /dev/null -exec ls -l {} \; |sort -n +4 |tail -30 Don't really understand the whole command, but your post text was helpful. This may do what you want: Code: [Select]echo off setlocal enabledelayedexpansion if exist dirList.txt del dirList.txt if exist sortedDirList del sortedDirList for /f "tokens=* delims=" %%i in ('dir c:\windows\system32 /s /b') do ( if %%~zi GEQ 9999999 echo %%~zi %%~dpni >> dirList.txt ) sort /r dirlist.txt /o sortedDirList.txt for /f "tokens=1-2" %%i in (sortedDirList.txt) do ( echo %%i %%j set /a count+=1 if !count! EQU 30 goto :eof ) You can change c:\windows\system32 to any valid directory. Good luck. Sidewinder, that's great, I just copied and pasted your code and then ran it as a batch file to test it, it worked brilliantly, however, if I try and replace c:\windows\system32 with the drive I need to CHECK, it doesn't seem to do anything at all... I know the screen stays blank whether it's doing anything or not, but there is no text file created when I try and use iton my network drive.. I have tried \\share\folder and z:\share\folder (for share\folder - this is my networked drive). Any ideas?I think you just have to be patient. I tested on a network directory (wireless) with 891 files. The script ran 25 minutes. I inadvertently left out a few file extensions and there is a major logic error because NUMBERS in batch are treated as text and do not right align which will throw off the sort. I added logic to fix this but now you need to use the choice command for this work. Sorry for the inconvenience. Code: [Select]echo off setlocal enabledelayedexpansion if exist dirList.txt del dirList.txt if exist sortedDirList.txt del sortedDirList.txt for /f "tokens=* delims=" %%i in ('dir c:\windows\system32 /s /b') do ( call :ZeroFill %%~zi if %%~zi GEQ 9999999 echo !var! %%~dpnxi >> dirList.txt ) sort /r dirList.txt /o sortedDirList.txt for /f "tokens=* delims=" %%i in (sortedDirList.txt) do ( echo %%i set /a count+=1 if !count! EQU 30 goto :eof ) goto :eof :ZeroFill echo;;|choice /c=%1; set > p.bat set ct=0 call p.bat for %%v in (%[%) do call set /a ct=%%ct%%+1 set [= del p.bat > nul set /a pad=12 - %ct% if %pad% equ 11 set var=00000000000%1 if %pad% equ 10 set var=0000000000%1 if %pad% equ 9 set var=000000000%1 if %pad% equ 8 set var=00000000%1 if %pad% equ 7 set var=0000000%1 if %pad% equ 6 set var=000000%1 if %pad% equ 5 set var=00000%1 if %pad% equ 4 set var=0000%1 if %pad% equ 3 set var=000%1 if %pad% equ 2 set var=00%1 if %pad% equ 1 set var=0%1 goto :eof Good luck. |
|