logo
down
shadow

"Do While" code doesn't loop through directory - only sees one file


"Do While" code doesn't loop through directory - only sees one file

By : PRATEEK GUPTA
Date : November 20 2020, 03:01 PM
Does that help Your loop only sees one file, because you are only executing Dir once (to get the first file). To make your loop work, you need to set Filename = Dir() to retrieve the next file.
code :
For x = 2 To ActiveWorkbook.Sheets("NumNF").Range("a1")

    numb_nota = ThisWorkbook.Sheets("controle").Range("C" & x).Value
    Name = "Nota Fiscal P&G número " & Left(numb_nota, 9) & ".PDF"

    Directory = "C:\Users\andrade.br\Documents\Test\"
    Filename = Dir(Directory & "*.PDF")

    Do While Filename <> ""

        If Name = Filename Then

            .Attachments.Add Directory & Filename
        End If
        Filename = Dir() ' retrieve the next file name
    Loop
Next
Directory = "C:\Users\andrade.br\Documents\Test\"
For x = 2 To ActiveWorkbook.Sheets("NumNF").Range("a1")
    numb_nota = ThisWorkbook.Sheets("controle").Range("C" & x).Value
    Filename = Directory & "Nota Fiscal P&G número " & Left(numb_nota, 9) & ".PDF"

    If Dir(Filename) <> "" Then
        .Attachments.Add Filename
    End If
Next


Share : facebook icon twitter icon
Output what Rspec "sees" to an HTML file

Output what Rspec "sees" to an HTML file


By : learner
Date : March 29 2020, 07:55 AM
Hope this helps You want to use 'save_and_open_page'. You may need to add 'launchy' to your gemfile. Once you do:
code :
before do
    #Create data here
    #
    #
    #sign user in here
    visit root_path
    save_and_open_page
end
FTP client sees a file that isn't there... How can I successfully delete/overwrite this "ghost" file?

FTP client sees a file that isn't there... How can I successfully delete/overwrite this "ghost" file?


By : Binni
Date : March 29 2020, 07:55 AM
Hope this helps for the non-help, the downvote, and the general lack of response on what was a pretty serious issue for me.
In case anyone else has a similar problem, here's what was going on:
When using "mv" command for moving and renaming, script sees it as a directory instead of new filename

When using "mv" command for moving and renaming, script sees it as a directory instead of new filename


By : Joost Wagenaar
Date : March 29 2020, 07:55 AM
it should still fix some issue mv requires the destination to be a directory only if more than one source argument is given.
In this case, that can be caused by your variables being split due to lack of quoting. Use double quotes -- as http://shellcheck.net/ directs -- around all expansions.
code :
for i in *.txt ; do
  mv "$i" "$NEWDIR/$NEWF"
done
"awk fatal cannot open file for reading (no such file or directory)" in for loop in bash script

"awk fatal cannot open file for reading (no such file or directory)" in for loop in bash script


By : victornjg
Date : March 29 2020, 07:55 AM
I hope this helps . I made a Bash script with an AWK script to read files with network pings and then calculate the parameters that the TCP protocol gets like timeout and estimatedRTT. , If you simply want to process all .txt files with AWK, you can do:
code :
awk '...' *.txt
awk: fatal: cannot open file `*.txt' for reading (No such file or directory)
shopt -s nullglob
Looping through files in ftp using ftplib returns "No such file or directory" in second loop

Looping through files in ftp using ftplib returns "No such file or directory" in second loop


By : Alexander Shepherd H
Date : March 29 2020, 07:55 AM
I wish this helpful for you open(filename, 'r+') opens a local file. While I believe you want to open a remote file.
You probably have a local copy of ffpos1_708524_57474156_18022019_036521_1.csv, but not of fflia1_708470_57474842_18022019_036521_1.csv. That would explain why open seemingly succeeds for the first iteration.
code :
for filename in files:
    if ".csv" in filename:
        flo = BytesIO()
        ftp.retrbinary('RETR ' + filename, flo.write)

        flo.seek(0)
        store_to_gcs(flo, filename)
shadow
Privacy Policy - Terms - Contact Us © voile276.org