Move 300 images from a folder (contains 800 images) to another based on file name list - excel

I need to move 300 images from a folder (contains 800 images) to another folder. The file name list of these 300 images are available in the excel format. Is it possible to move them via programming instead of search the file and move it one by one? Our IT told me he can't separate these files. Do you have any solution? Many thanks in advance!!!

Here's one way of doing this - I am assuming you are on Windows. First, save text file called ListOfImages.txt that contains the names of the images you wish to move - put one image on each line and include the extension. Then, save the following into a file called movefiles.cmd:
#echo off
set Source=C:\Users\YourName\Desktop\moving\MovingFrom
set Target=C:\Users\YourName\Desktop\moving\MovingTo
set FileList=C:\Users\YourName\Desktop\moving\ListOfImages.txt
echo.
if not exist "%Source%" echo Source folder "%Source%" not found & goto Exit
if not exist "%FileList%" echo File list "%FileList%" not found & goto Exit
if not exist "%Target%" md "%Target%"
for /F "delims=" %%a in ('type "%FileList%"') do move "%Source%\%%a" "%Target%"
:Exit
echo.
echo press the Space Bar to close this window.
pause > nul
You will want to change the variables for Source, Target, and FileList to match where you have those folders and the ListOfImages.txt on your machine. After you have saved this file (make sure it has the .cmd extension, you should be able to double-click it and it will run the commands in your Command Prompt.
For example, say my MovingFrom folder contains the following:
And I only want to move Image1.png and Image2.png -- then my ListOfImages.txt file would like this:
After running moveFiles.cmd (provided I have changed the necessary variables to point to the right folders/places on my machine), my MovingTo folder should contain the following:
Notice that Image2.png was not moved because it was not listed in the ListOfImages.txt text file.

Related

How to remove dead files from Open Recent list in Sublime Text 3?

In Sublime Text 3 if I go to:
MENU: File>Open Recent
There are files in that list which are no longer available.
How can I clean that list of dead files?
I don't want to clear the full list, just the dead ones.
Note: I've followed How to increase number of recent files in Sublime Text 3? to get 30 recent files showing in this menu.
Following this post over on the Sublime Forum it can be done by editing the Session.sublime_session file.
For example: I'd edited etc/hosts so I could block myself from watching youtube, but with it being in the recent files list in Sublime it's easy to unblock myself thus I wanted to remove /etc/hosts from my recent file list in Sublime (ST3).
My copy of Sessions.sublime_session is in ~/.config/sublime-text-3/Local/ from which I deleted all lines containing etc/hosts.
The only caveat is that you can't edit that file using Sublime, Sublime should not be running, I used a different text editor.
Final caveat this is the solution for linux, and ST3, for windows and mac I'm guessing there's something similar.
I found out how to do this using this python script here:
https://github.com/STealthy-and-haSTy/SublimeScraps/tree/master/session_cleaner
I don't want to post the python code as I don't have permission to do so but that has been up on GitHub for a couple of years so there should be no worries of it disappearing anytime soon.
I've written a batch file that will start the python file, see the code below. Just name it RunSessionCleaner.cmd and place this in the same folder as the sublime_session_clean.py file.
#echo off & title %~nx0 & color 5F & chcp 65001 >NUL
rem Based on this thread here: https://stackoverflow.com/a/13351373
goto :MY_ROUTINE
:CMD_SIZE
chcp 850 >NUL & set "uiWidth=%1" & set "uiHeight=%2"
mode %uiWidth%,%uiHeight%
if %4==TRUE (set /a "uiHeightBuffer=uiHeight+%3")
if %4==TRUE (powershell.exe -ExecutionPolicy Bypass -Command ^
"&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%uiWidth%;$B.height=%uiHeightBuffer%;$W.buffersize=$B}")
if %4==FALSE (powershell.exe -ExecutionPolicy Bypass -Command ^
"&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%uiWidth%;$B.height=%uiHeight%;$W.buffersize=$B}")
chcp 65001 >NUL & goto :EOF
:MY_ROUTINE
call :CMD_SIZE 60 7 222 TRUE
title Cleaning folders, files and projects...
echo Cleaning folders, files and projects...
:: Full path to data folder W:\Apps (Portable)\Sublime Text\Data
:: Full path to python.exe W:\Apps (Portable)\Sublime Text\Data\Packages\User\SessionCleaner\python\python.exe
:: Full path to sublime_session_clean.py W:\Apps (Portable)\Sublime Text\Data\Packages\User\SessionCleaner\sublime_session_clean.py
:: Or like I have done use a relative directory to the Data folder
:: The SsssionClearner.py file is located in: W:\Apps (Portable)\Sublime Text\Data\Packages\User\SessionCleaner
::
:: Change this line below to suit your needs.
".\python\python.exe" "sublime_session_clean.py" --data-dir "..\..\..\..\Data" --workspaces --files --folders
echo/
goto :EXIT_ROUTINE
:EXIT_ROUTINE
rem call :CMD_SIZE 100 10 222 FALSE
title Exiting routine...
echo Exiting routine...
set /p "=" <NUL &
ping localhost -n 3 >NUL & exit
exit
Change line 24 of the code above to suit your paths. You can just use relative paths here like I have done so you can do that too.
This batch file can be clicked on or set up in Task Scheduler to start up when the PC does to clean out all the non-existent files or workspaces.
Please note, Sublime Text needs to be closed in order for this to work.

Search for a file and open the path in CMD

I would like to achieve the following in CMD:
Will search for a specific filename - This I know how to do, with dir /s filename
Once found it will bring me to that path.
Example: I am now on C:\, if that file was found in C:\test then it will open C:\test in command prompt.
Alternatively, I would like just to copy the found file to a path I will specify. I just don't know how to do it, since I don't know the path where the file will be stored (it's different every time).
Thanks in advance!
I'm a liitle confused with your question but I will try to walk you through a batch code I wrote to help you with this.
dir /b /s "test.txt" > "%userprofile%/Desktop/result.txt"
::find the file path to the file you want to find and insert it in a .txt file
::you made called result.txt (also %userprofile% is a variable that brings you to
::your user directory ex C:/users/admin)
for /F "tokens=*" %%A in (%userprofile%/desktop/result.txt) do (
set var1=%%A
)
::set the variable var1 equal to the first (well... only) line in the file.
::I could explain what that for loop means in detail but just remember that %%A
::is a variable set from what was found when looping through the result.txt.
xcopy /s "%var1%" "C:/wherever/you/want/it/to/go"
did this help??

move files name in excel to a specific folder

I am trying to write a batch file that reads from excel file. then move them to a specique folder.
lets say in the excel , there are:
111.txt
222.txt
333.txt
512.txt
I want a batch file that move files into a specific directory that have the above names.
how can I achieve that ?
(I am using xp , and I the directory is D:)
cd /d "d:\files"
for /f %%i in ("C:\where the file resides\file.csv") do (
echo move "%%i" "D:\New\"
)
remove the echo if output seems ok

I would like a script to search within text files a certain pattern of strings and move those files to another directory

I need to know how to perform an advanced search on a text file using tools like notepad++, freecommander and windows if possible. A bat script file will be great.
The problem is that i need to search through about 1000 txt files in a directory. I need to know form those 1000 txt files which have a string in the form of for example "SYR_SHA/245/4". I just want it search for the pattern for example *****_******/*****/****** where * are characters that can change in number.
There must be an _ between the first and second set of characters as seen above in the example.
the script should go through the entire txt file and search for the above pattern. The script should then Move all the results in to a seperate directory
Many Thanks
Create this batch file and copy it into your folder where you have all the 1000 .txt files
Change the yourdestinationdirectory directory and run the batch file
#Echo Off
FindStr /M /R "[a-zA-Z]*_[a-zA-Z]*\/[0-9]*\/[0-9]*" *.Txt > findstr.out
For /F "tokens=*" %%a In (FindStr.out) Do call :move_Rtns %%a
del FindStr.out
Exit /B
:move_rtns
copy %1 yourdestinationdirectory\*
del /Q %1
Exit /B
Please change the Regex according to your requirement, for eg. If you are expecting number and letter together you can replace [a-zA-z] with [a-zA-Z0-9]
Good luck

How to add files/folders to multiple zip files at once with WinRAR?

Is there any way to add files/folders to multiple zip files at once. For example:
Updates:
folder1
folder2
file1
file2
Archives:
archive1.zip
archive2.zip
archive3.zip
I need to add updates to all archives without opening all of them and pasting updates in there.
Any way to do this?
Or is there another archive program that can do this?
This can be done using a batch file and for example WinRAR.
#echo off
if not exist archive*.zip (
echo There are no archive*.zip files to update in
echo.
echo %CD%
echo.
pause
goto :EOF
)
set "ErrorCount=0"
for %%I in (archive*.zip) do (
"%ProgramFiles%\WinRAR\WinRar.exe" u -afzip -cfg- -ep1 -ibck -inul -r -y "%%I" folder1 folder2 file1 file2
if errorlevel 1 (
echo Error on updating %%I
set /A ErrorCount+=1
)
)
if not "%ErrorCount%" == "0" (
echo.
pause
)
set "ErrorCount="
For each archive*.zip file WinRAR is called to update the ZIP file with the two folders and the two files.
The batch processing finishes without printing any message and without pausing if all ZIP files found could be updated successfully. Otherwise the batch file outputs which ZIP file could not be updated for example because of read-only attribute set, and pauses the batch processing before finishing so that the user can read the error message(s).
For details on the WinRAR command u and the used switches open in WinRAR from menu Help the Help topics, open on tab Contents the item Command line mode and read at least the help pages:
Command line syntax
Commands - Alphabetic commands list
Switches - Alphabetic switches list
For understanding the other used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
echo /?
for /?
goto /?
if /?
pause /?
set /?
You can do it by using 7zip command line version
7z a archive1.zip dir\ -v10k -v15k -v2m #listfile.txt
this will do archive all files and folder is in that folder named 'dir'
and first volume will be 10kb, second will be 15kb and others will be 2mb each except last
and you can use a file that has list of all files named.

Resources