none
Windows Batch Scripting RRS feed

  • Question

  • Hello guys i am new in this forum...!

    i am writing the script in notepad (.bat) file. i am stuck on some point.

    1- i have SHA1 exe on c drive. 

    i have 24 backups file for the Database and i want to create 24 sha 1 for each file ? i am using code 

    cd %DB_Backups%\Backups\TEST\
    for /r c:\Backups\TEST %%f in (*) do (
    echo Creating sha1
    %Hashing_Sha1% %DB_Backups%\Backups\TEST "%%f" >> Backup.SHA1
    )

    this code create only one SHA1 file for all files.
    please let me know if you guys have solution.

    Tuesday, July 25, 2017 1:51 PM

Answers

  • Use PowerShell 4.0 or later.


    $path = Join-Path $Env:DB_Backups Test
    Push-Location $path
    Get-ChildItem -File -Recurse |
      Get-FileHash -Algorithm SHA1 |
      Export-Csv HashValues.csv -NoTypeInformation
    Pop-Location
    


    -- Bill Stewart [Bill_Stewart]

    Tuesday, July 25, 2017 2:56 PM
    Moderator

All replies

  • Use PowerShell 4.0 or later.


    $path = Join-Path $Env:DB_Backups Test
    Push-Location $path
    Get-ChildItem -File -Recurse |
      Get-FileHash -Algorithm SHA1 |
      Export-Csv HashValues.csv -NoTypeInformation
    Pop-Location
    


    -- Bill Stewart [Bill_Stewart]

    Tuesday, July 25, 2017 2:56 PM
    Moderator
  • MD5  and SHA1 is working on each file 

    for example I have 10 files  each files have MD5 and SHA1

    file.txt+md5+sha1 => i want to compress each compress with MD5 and SHA1

    file2.txt+md5+sha1 => compress seperately 

    file3txt+md5+sha1 => compress seperately etc

    any idea ?

    Tuesday, July 25, 2017 3:20 PM
  • MD5 and SHA1 aren't compression algorithms. They are hashing algorithms.

    I refer the honorable gentleman to the answer already given a short time ago.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, July 25, 2017 3:42 PM
    Moderator
  • yeah i got that answer about HASHING now my question is about compressing the file 7z

    how do i create 7z for each file i want to compress them i have 24 files 

    i want to compress each of them seperatley. 

    Tuesday, July 25, 2017 3:48 PM
  • "C:\Program Files\7-Zip\7z.exe" a backup_cbk.7z

    thats the code i m using

    Tuesday, July 25, 2017 3:49 PM
  • yeah i got that answer about HASHING now my question is about compressing the file 7z

    If you have a separate question, start a new question thread. Remember to be very specific about your question.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, July 25, 2017 4:19 PM
    Moderator
  • i just post seperately  please suggest.

    i am making a batch script which contain my backup files+hashing+ compressing.

    my script working HASHING things 

    my question is I have 24 files and i want each 24 files to be ZIP separately.

    I dont want my file 24 file to zip together. Thanks please reply

    Example:

    file1.txt  ==> file1.7z

    file2.txt  ==> file2.7z

    file3.txt  ==> file3.7z

    Tuesday, July 25, 2017 4:44 PM
  • You need to open a new question as you are now asking something not related to this thread.

    Please start a new question.


    \_(ツ)_/

    Tuesday, July 25, 2017 4:51 PM