User Profile

Collapse

Profile Sidebar

Collapse
tcurdts
tcurdts
Last Activity: Jul 24 '07, 10:17 PM
Joined: Jun 5 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • I'm still not sure why the variables weren't getting set right away but I figured out an alternate method.

    Instead of setting variables on lines 24, 25 and 26 (code from original post) I used "tokens" in the FOR statement to parse the filenames, for use on line 7 below. The relevant portion of the new code looks like:
    Code:
    set hlist=%outtar%\hdrList.txt
    FOR /F "tokens=1,2* delims=." %%y in (%hlist%)
    ...
    See more | Go to post

    Leave a comment:


  • Thanks. I've seen that page but still can't figure out why my variables don't seem to be set immediately...
    See more | Go to post

    Leave a comment:


  • One more thing...

    Line 24 of the code is where it starts to fall apart. That variable seems to be set, but not utilized until the next time the program is run.

    Thanks again...
    See more | Go to post

    Leave a comment:


  • tcurdts
    started a topic FOR loop variables - not utilized immediately

    FOR loop variables - not utilized immediately

    Greetings,

    I'm using WindowsXP Pro v5.1and am writing a BAT file to loop through a list of files (contained in a .txt file) and pass them (actually variables derived from them) to another program (ERDAS Imagine). What appears to be happening is that the FOR loop isn't utilizing the variables until the 2nd iteration after the variable is set. Since one variable is dependent on another, I have to run the program 3 times before the...
    See more | Go to post

  • tcurdts
    replied to calling tar commands
    Sooo sorry... I had the paths wrong in the textfile; the files I was trying to hit were one level up. doh!!

    It's working beautifully. I have more development ahead but will start a new thread if/when I get stuck.

    Thanks again for all your help.

    with tail between legs,
    Thom
    See more | Go to post

    Leave a comment:


  • tcurdts
    replied to calling tar commands
    Nope. The only thing I changed was getting rid of the apostrophes and now I'm back to double back-slashes in the error msg:

    IOError: [Errno 2] No such file or directory: 'C:\\WorkSpace\ \LTC\\MRLC_test \\NZT\\tmp\\NZT 070830130627200 100.tar'

    The path strings in the text file are just as you'd see them in Windows:

    C:\WorkSpace\LT C\MRLC_test\NZT \tmp\NZT0708301 30627200100.tar
    See more | Go to post

    Leave a comment:


  • tcurdts
    replied to calling tar commands
    Dear ilikepython,

    Thanks for hanging in there w/ me. I'm still screwing up the strings; now I'm getting quadruple back-slashes!

    I tried to make your changes and here's the code followed by the error msg and my text file example:

    Code:
    import os, os.path
    import fileinput
    import tarfile
    
    path = r"C:\WorkSpace\LTC\MRLC_test\NZT\tmp"
    tfile = r"tarList2p.txt"
    ...
    See more | Go to post

    Leave a comment:


  • tcurdts
    replied to calling tar commands
    Nope, I don't really want interactive raw_input, but thanks anyway.

    As i've got it set up now, the textfile (tarList2.txt) just has a list of file names w/out paths:
    NZT070830130627 200100.tar
    NZT070830140710 200000.tar
    etc...

    When I have the txt file and the script in the same directory as the tar files, it works fine and extracts the files in the same directory.

    What I'd like to do...
    See more | Go to post

    Leave a comment:


  • tcurdts
    replied to calling tar commands
    Thanks much!! I've got the code working (untarring files contained in a txt file) when the python script is located in the same directory as the tar files.

    Two more questions:
    1) How do I specify different input and output directories so I can run the script from a different location and put my output (untarred files) in yet another directory?
    2) Is there redundancy in lines 5 and 8?

    Here's the code that's...
    See more | Go to post

    Leave a comment:


  • tcurdts
    replied to calling tar commands
    Sorry... meant to include the error. I included my code in my original posting to show that I've at least been trying, but I'm so green that I suspect there's a better, cleaner way to do this.

    Here's the error msg (trailing newline):

    Error Message:
    Traceback (most recent call last):
    File "C:\Python24\Li b\site-packages\python win\pywin\frame work\scriptutil s.py", line 310, in RunScript
    ...
    See more | Go to post

    Leave a comment:


  • tcurdts
    started a topic calling tar commands

    calling tar commands

    I think what I’m trying to do is very basic but I’m a rank beginner and I’m stuck. I’m using Python 2.4.1 on WindowsNT. I’ve installed UnxUtils, which includes the tar commands for Windows.

    Immediate objective:
    I have a text file containing a list of tar files, one filename per line. For now I’m just trying to loop through my text file and untar each file in the list.

    Background/big picture:...
    See more | Go to post
No activity results to display
Show More
Working...