topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 1:07 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Cut and paste list of files ?  (Read 13065 times)

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 126
    • View Profile
    • Donate to Member
Cut and paste list of files ?
« on: July 04, 2013, 01:26 PM »
Hello,

I have a list of files ("!Not_Searchable.txt") created using the great freeware PDFTextChecker (https://www.donation...ex.php?topic=27311.0).

Here is an example of what is inside the text file (it may contains accents or non-ASCII characters) :
F:\1_B\2003\01 2003\important\publication 01 2003\Béec2002.pdf
F:\1_B\2003\01 2003\important\publication 01 2003\Béec2001.pdf
F:\1_B\2003\01 2003\important\publication 01 2003\Béec2000.pdf
...
etc
...
(note: there are thousands of rows)

I would like to cut and paste those files into another folder.
I have tried the freeware Puresync (http://www.jumpingby...com/en/puresync.html) but it is too buggy alas (not transferring every files...). ;(

Any other idea ?
Thanks in advance ;)





mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #1 on: July 04, 2013, 01:38 PM »
Quick reply but not complete answer:

You can paste a list of files like that into my Drag+Drop Robot:
https://www.donation.../dragdrop/index.html

Once you do that though, you'll have to have it invoke a commandline file mover/copier to actually DO something with those files.

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #2 on: July 04, 2013, 04:35 PM »

- Use SED or any other text editor

-add in front of all lines

MOVE "


-add at end of all lines

"       "X:\new\path"


That should get you
MOVE "F:\1_B\2003\01 2003\important\publication 01 2003\Béec2002.pdf"      "X:\new\path"
MOVE "F:\1_B\2003\01 2003\important\publication 01 2003\Béec2001.pdf"      "X:\new\path"
MOVE "F:\1_B\2003\01 2003\important\publication 01 2003\Béec2000.pdf"      "X:\new\path"
...
etc


- save with .CMD extension and execute


You may want to try with one or two files only and maybe with COPY instead of MOVE first.
Open a command line window and type 'move /?' to read more.



 

Tinman57

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,702
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #3 on: July 04, 2013, 08:28 PM »
  I use a program called Piky Basket that adds itself to the RMC menu on Windows Explorer and other file management programs.  You highlight what you want to copy or move and select "Drop in Basket".  The RMC on another folder and select either Copy All or Move All.  I use it anytime I'm copying/moving files, especially when I'm copying and moving the files to two different drives.  When you select the copy option, it copies the files but leaves them in the basket until you either move the files or empty the basket.  You also have the option to select only certain files to be copied/moved.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #4 on: July 05, 2013, 12:05 AM »
From the command line:

for /f "tokens=* usebackq" %I in (`type "!Not_Searchable.txt"`) do move "%~I" newdrive:\newpath

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 126
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #5 on: July 06, 2013, 04:58 AM »
Dear all,

Thanks for your answers. ;) After several tried I still blocked ! ;(

>Mouser
I can add my list of files but I don't know which command line to use.

>AbteriX
It is working but not for all files : non-ascii characters.
 
>4wd
"0" files are copied in my command line. see image :
http://postimg.org/image/43ujlomax/


Thanks in advance ;)


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #6 on: July 06, 2013, 06:48 AM »
>4wd
"0" files are copied in my command line.

Interesting, seemed to work here on a test.

That's not a backquote (`) you used in the command, that's an apostrophe.

backquote is above the TAB key.

2013-07-06 21_48_15-keyboard.jpg (JPEG Image, 2883 × 1012 pixels) - Scaled (35%) - Pale Moon.png

Although, you'll most likely end up with the same result as Abterix' method since they're both DOS based.

If your text file contains Unicode characters you can try the following at a command line:

Code: Text [Select]
  1. chcp 65001
  2. for /f "tokens=* usebackq" %I in (`type "!Not_Searchable.txt"`) do move "%~I" newdrive:\newpath

It changes the code page to UTF-8 for that CLI session. Here's a list in case you need something other than UTF-8.
« Last Edit: July 06, 2013, 08:21 AM by 4wd »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #7 on: July 06, 2013, 09:49 AM »
Seems like a good candidate for a simple AHK drop target.  Have the shortcut of an ahk program on the desktop.  Drag the file list and drop it on the icon.  Click the "open with" that Explorer gives you.  Then what remains is selecting the target folder.  The AHK program could use a BrowseForFolder dialog etc..

If you do this operation quite a bit you may want to request a Coding Snack.  That is, if you think the drag & drop method would be convenient.

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 126
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #8 on: July 07, 2013, 03:41 AM »
Hi,

Many thanks "4wd" ! ;))

This is very good ! ;))

I have another request if it is  possible :
Sometimes I have I have one file in a folder that has the same name (but not the same content) than another one into a subfolder. Then the command line asks me to choose : would I like to overwrite such file or not.
The problem being that it can erase a good pdf file.
It would be great if it could keep the same folder and sufolders structure than the source. Like that I would be sure that there won't be any overwriting. ;)

Or if that is not possible, always rename automatically the new filename by appending some numbers at the end for instance.

[The following is just for fun as I think I have a solution :
- I did a test with one accent inserted in the filename of a valid pdf file :
"111éjojd.pdf"

Code: Text [Select]
  1. chcp 65001
  2. for /f "tokens=* usebackq" %I in (`type "C:\prog\PDFTextChecker\1.txt"`) do copy "%~I" G:\transfer
(By the way I have used this tip for copying the above code on the command line : http://www.techspot....te-cmd-using-ctrl-v/ )

note: If I remove the accent "é", the file can be copied. ;)

I have tested with :
- UTF-16 => error I when I type chcp 1200 ("coding page not valid")
- UTF-8
- chcp 1147 (France)
- chcp 20297 (France)

Alas each time the file was not copied. ;(

My solution is to use a renamer : the great freeware "Bulk Rename utility" http://www.bulkrenam...y.co.uk/Download.php and remove "accent" and "Symbols". ;)
]


Thanks in advance ;)
See ya
ps: Thanks for the idea "MilesAhead", I'll prefer "4wd"'s way for now. ;)

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #9 on: July 07, 2013, 07:26 AM »
Duplicates paths.

CopyFileList.cmd <dest path> <file list>

eg.

CopyFileList.cmd G:\transfer C:\prog\PDFTextChecker\1.txt

Put quotes around arguments with spaces.

See below

Activating Quick Edit is one of the first things I do on a new system.
« Last Edit: July 12, 2013, 02:47 AM by 4wd »

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 126
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #10 on: July 07, 2013, 08:17 AM »
Many thanks "4wd". ;)
I have tried your script.
I added "CopyFileList.cmd" into the root of C:\prog\ (I also tried C:\)

and execute (run) : C:\prog\CopyFileList.cmd G:\transfer C:\prog\PDFTextChecker\1.txt

It copied only the first listed pdf file (with its full directory structure) and no other pdf file.

Thanks in advance ;)

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #11 on: July 07, 2013, 08:28 PM »
Remove @echo off and run it again.

Also, you need to provide more info, eg. OS, language (I'm assuming French), etc

And an attached shortened example of the file list, so we know what encoding the file is in, containing at least one line where it fails at.

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 126
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #12 on: July 11, 2013, 02:53 AM »
Many thanks "4wd" ;)

I  have removed "@echo off".
I have tried several things and it seems to work for simple folders and filenames. But strangely it doesn't does not work for all.

C:\prog\CopyFileList.cmd G:\transfer\ C:\1\!Not_Searchable.txt

I am adding an example that is not working for me (only one file is copied. If I have similar more paths, it copies only the first file).

I am on Win7 64 Bits. My language is french. I have removed accent from filenames.

Thanks in advance ;)

edit: file uploaded as a zip file this time
« Last Edit: July 12, 2013, 12:31 AM by jity2 »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #13 on: July 12, 2013, 02:38 AM »
OK, the following worked here, (on Win7 x64), using the files you sent and this command, (!Not_Searchable.txt was in same directory as command):

CopyFileList.cmd R:\test\test "!Not_Searchable.txt"

!Not_Searched.txt (note the accented e)
U:\test\1_ztestpdf\1_ABCi\2003\AHYEDKI 01 2003\important\Dopmdanen 2 zuuk\old accent e a - Copie.pdf
U:\test\1_ztestpdf\1_ABCi\2003\AHYEDKI 01 2003\important\Dopmdanen 2 zuuk\old accent é a.pdf

CopyFileList.cmd
Code: Text [Select]
  1. Rem CopyFilelist.cmd <dest path> <file list>
  2. @echo off
  3. chcp 28591
  4. setlocal EnableExtensions
  5.  
  6. if exist "%~1" goto :CheckList
  7. echo Destination does not exist
  8. goto :End
  9.  
  10. :CheckList
  11. if exist "%~2" goto :Copy
  12. echo No file list entered
  13. goto :End
  14.  
  15. :Copy
  16. for /f "tokens=* usebackq" %%I in (`type "%~2"`) do (
  17.     if not exist "%~1%%~pI" md "%~1%%~pI"
  18.     copy "%%~I" "%~1%%~pI"
  19. )
  20.  
  21. :End

All I've done above is change the codepage to the same as Windows normally uses, (ISO 8859-1 Latin 1; Western European (ISO)).

Also, it now checks to see if the destination directory exists before creating it.
« Last Edit: July 12, 2013, 02:48 AM by 4wd »

jity2

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 126
    • View Profile
    • Donate to Member
Re: Cut and paste list of files ?
« Reply #14 on: July 12, 2013, 03:10 AM »
Wow! Many thanks "4wd". ;)
I'll do more testing but this is working great so far. I even don't have to rename all my files. ;)
Thank you again. ;)
See ya