Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 68,074 of 68,980    |
|    =?UTF-8?B?SsO8cmkgVGFzdWph?= to Herbert Kleebauer    |
|    Re: move a fixed number of files between    |
|    06 Jul 23 12:47:34    |
   
   From: tarbija6@gmail.com   
      
   On Thursday, 6 July 2023 at 19:59:41 UTC+3, Herbert Kleebauer wrote:   
   > On 06.07.2023 12:59, Jüri Tasuja wrote:    
   >    
   > >> set SourceDir=E:\    
   > >> set TargetDir1=E:\new1\    
   > >> set TargetDir2=E:\new2\    
   > >>    
   > >> set n=0    
   > >> for /f %%i in ('dir /b /on "%SourceDir%*.jpg"') do call :sub %%i    
   > >> goto :eof   
   > > Many thanks for script! Unfortunately I can't get it working.    
   > > I have tested it and the script itself is working just perfectly    
   > > but it fails when moving files where it gives message "Access denied".   
   > "Move" can only be used when source and destination are on the    
   > same drive. To avoid problems with different drive letters    
   > assigned to the external drive, I would do it manually:    
   >    
   > After connecting the external drive, use Windows Explorer to    
   > copy all the jpgs to a local folder, for example to d:\my_jpgs    
   > and use:    
   >    
   > set SourceDir=d:\my_jpgs\    
   > set TargetDir1=d:\my_jpgs\new1\    
   > set TargetDir2=d:\my_jpgs\new2\    
   >    
   > in your batch file (don't forget to create the two target    
   > directories or create them in the batch if they don't exists).    
   >    
   > If all is ok, use Explorer to delete the jpgs on the external    
   > drive and to unmount the drive.   
      
   Thanks again I got it working! I understood my mistake, I had one extra   
   subfolder between pictures and C: drive. These "move" and %~z are quite picky   
   functions. Meanwhile I found one script from Stackoverflow by XFlak who claims   
   that it gets file size    
   from every directory (external etc.). Script added below:   
   set file=C:\Users\Admin\Documents\test.jpg   
   set /a filesize=   
   set fileExclPath=%file:*\=%   
      
   :onemoretime   
   set fileExclPath2=%fileExclPath:*\=%   
   set fileExclPath=%fileExclPath2:*\=%   
   if /i "%fileExclPath%" NEQ "%fileExclPath2%" goto:onemoretime   
      
   dir /s /a-d "%workingdir%">"%temp%\temp.txt"   
   findstr /C:"%fileExclPath%" "%temp%\temp.txt" >"%temp%\temp2.txt"   
      
   set /p filesize= <"%temp%\temp2.txt"   
      
   echo set filesize=%%filesize: %fileExclPath%%ext%=%% >"%temp%\temp.bat"   
   call "%temp%\temp.bat"   
      
   :RemoveTrailingSpace   
   if /i "%filesize:~-1%" EQU " " set filesize=%filesize:~0,-1%   
   if /i "%filesize:~-1%" EQU " " goto:RemoveTrailingSpace   
      
   :onemoretime2   
   set filesize2=%filesize:* =%   
   set filesize=%filesize2:* =%   
   if /i "%filesize%" NEQ "%filesize2%" goto:onemoretime2   
      
   set filesize=%filesize:,=%   
   echo %filesize% bytes   
      
   SET /a filesizeMB=%filesize%/1024/1024   
   echo %filesizeMB% MB   
      
   SET /a filesizeGB=%filesize%/1024/1024/1024   
   echo %filesizeGB% GB   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca