0

I have a Python script (but it could be as well a batch script) that receives filenames as input and I was able to make it work with drag and drop, retrieving the filenames arguments from sys.argv, but I suddenly discovered that I cannot drop more than a about 100 files (the number is variable depending of filenames length I guess) due to the Windows 10 shell limitations. It's not rare to have a few thousands files inside a folder, so I need a way to pass so many filenames at once to the script.

I would like to avoid to add a full interface to my short Python script just to select many files at once. How can I overcome those Windows 10 limitations?

There must be some way, since I'm able to select and send without problems (at least) 15000 files to "7Zip -> Add to archive" context menu or to "SendTo -> Compress folder" context menu (using context menu for my script would be a perfect solution).

Here is a test Python script:

# real script requires the activation of a specific Conda environment
import sys
print(sys.argv)

To allow drag and drop on this Python script I created a file link to the script. The "Destination" field of the file link, on which I drop the selected files, is:

C:\Users\<user>\Miniconda3\Scripts\activate.bat <environment> && C:\Users\<user>\Miniconda3\envs\<environment>\python.exe "<drive>\<path>\my_python_script.py"

Follow up

I found out that dropping files on the window of an opened application, instead of on a script, does not have the limitation on number of files, and this let me solve my original problem (here an example). However, I still hope that a solution to overcome the limitation on number of files dropped on a script can be found, as it would still be very useful for batch files.

mmj
  • 5,514
  • 2
  • 44
  • 51
  • Command line (curl, ffmpeg) programs offten read list of incoming files from a text file. – viilpe Mar 21 '21 at 11:37
  • @viilpe I can read a text file from Python too, but in creating such text file, for example by dropping the selected files to a `.bat` file made by `echo %* > filelist.txt` you hit in the same Windows limitations I'm talking about. – mmj Mar 21 '21 at 18:15

0 Answers0