-2

I have a python script handling conversion of FIX (xml/json type) data. However under windows the argument * does not work to select all files for processing. However it does work under bash windows. Any way to circumvent/address this behavior?

mart
  • 49
  • 5
  • 2
    This sounds like it has nothing to do with Python, and everything to do with your expectation of how the environment (`bash` vs `cmd`?) from which you *run* your script behaves. – chepner Jul 04 '22 at 22:05
  • This code is not properly formatted. Please [edit] to fix it. If needed, refer to [code formatting help](/editing-help#code). But more importantly, what do you mean by "does not work"? That is, what do you expect to happen, and what happens instead? Please provide a [mre]. – wjandrea Jul 04 '22 at 22:45
  • Oh actually, I think I get what you're saying. The problem you're probably experiencing is that CMD doesn't do file wildcards, which has nothing to do with Python. Check out these questions: [Is there any way to get the windows cmd shell to expand wildcard paths? - Super User](https://superuser.com/q/460598/443564), [Filename globbing Windows vs. Unix](/q/11557280/4518341) – wjandrea Jul 04 '22 at 22:50
  • but cmd works with other commands. like for example if i do a copy * that works or a del * or move *. all of these work – mart Jul 04 '22 at 23:14

1 Answers1

0

As it seems windows cannot handle wildcards on it's own for file expansion. The individual binaries like copy, move etc handle on their own. The solution here is to add a loop to pass on each filename to the script:

FOR %%i IN (*.log) DO convert_FIX.py %%i
gab
  • 792
  • 1
  • 10
  • 36
mart
  • 49
  • 5