Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

How can I do This?

  • 03-02-2009 4:56pm
    #1
    Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭


    I have a list of file names from a CCTV system & they are listed one on each line. (there is no facility to view them in any other order)

    If I copy a selection of them (like below) & paste them into a Text file

    File001.wmv
    File002.wmv
    File003.wmv
    File004.wmv
    File005.wmv
    File006.wmv

    Is there anyway (maybe using a batch file or something) to put them into the following order with each file separated by a comma? (see below)

    File001.wmv,File002.wmv,File003.wmv,File004.wmv,File005.wmv,File006.wmv



    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Comments

  • Registered Users, Registered Users 2 Posts: 2,191 ✭✭✭Feelgood


    If you do a 'find' on the text file, then look for the single character 'v' there should be an option to do a replace on it. Just replace it with 'v,'


  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Feelgood wrote: »
    If you do a 'find' on the text file, then look for the single character 'v' there should be an option to do a replace on it. Just replace it with 'v,'

    Thanks for that suggestion but it still won't put them in a line?

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 2,191 ✭✭✭Feelgood


    You never said nothing about no lines brother!! :p

    Will have a look for you now,

    What text editors have you got on hand?

    EDIT: Actually why do you need them in a line?


  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    Copy from the text file, into Word. Then in Word, do an advanced Replace, and replace

    v^p
    with
    v,

    that should do it for you.


  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    And for readability (if you like) make it v comma space


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Feelgood wrote: »

    EDIT: Actually why do you need them in a line?

    I didn't want to complicate the issue but seeing as you asked!

    The file names are displayed in the DVR software & are not manipulable in any way at all (you can't highlight, copy or paste) so I have to use an OCR screen capture to grab the required files & then paste them into a txt file.

    The file list in the DVR is only a snapshot of the actual files which are stored in a separate folder on the HDD (hundreds of them from 16 cameras).

    The problem is that they are not in any particular order so if I want to recover a certain time capture from a particular camera I want to be able to paste the line of files into Windows search so as it lists those files only in the search result.

    Are you still with me?

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    What system is the DVR on - is it on a computer that's running Windows or Linux for example? How are you getting the screen capture onto your machine in the first place?

    If the whole thing is in Windows, is the problem that the time capture is just too slow?

    So, to simplify an example, say you just have two cameras, and there's 10 files each. You want to find the snippet for camera 1, at 10pm on Tuesday, Feb 5th.

    So what are you searching in Windows? Are the files

    Camera1/file001.wmv last saved at 23:00 5/2/09 ?

    Is there a separate folder for each camera? Or are all the files in a single big folder, with nothing distinguishing the camera? If it's not terribly confidential information, maybe post a screenshot of the folder for us to help explain. While my suggestion in the posts above will help, I bet there's an easier way to do what you're doing :)


  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    The actual files are being stored on 4 1TB drives accessible via Windows.

    And yes, all the files for all the cameras are in the same folder & not separate ones. (that's really where the problem is).

    I'm not at the system at the minute but I think the name of the capture software is OCR Screen Capture v6.

    The DVR software displays all the files by camera & they are all time & date stamped & the OCR capture lets me grab the ones I want & paste them into a text file.

    Then I need to pump them into windows search to locate only those files in the huge folder of files.

    It's the dumb ass software on the DVR really, it should have a feature to let me take a particular time and date snippet easier then this?

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    I can get Excel to do it but it's still a pain in the Ass....

    cctvtrial4zu2.jpg


    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    Well, if you have Excel, I'm going to assume you have Word, and I've created a macro for you to do what you want.

    Sub ColumnToList()
    '
    ' Macro to convert column of file names to a list
    ' Macro created 03/02/2009 by Thoie
    '
    
    ' Start by clearing everything in the find/replace boxes 
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
    
    ' Find the end of each row
            .Text = "^p"
    
    ' Replace with a comma thereby putting things on a single row
            .Replacement.Text = ","
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    

    If you're not familiar with macros in Word, open a blank document. Press ALT-F8.
    Type "ColumnToList"
    Press "Create"
    Delete everything you see in the box that appears.
    Paste my code in that box
    Close until you see the blank Word doc again.

    Now paste in your list of files, hit ALT-F8 and "run" the ColumnsToList and it will do it all for you. If you know about macros already, assign the macro to a toolbar button for future use. If not, go read up on macros and assigning shortcuts/buttons to them :)

    I still think if we could see a screenshot of the way the DVR is storing things we could probably work out a DOS batch file to find what you want, thereby skipping the whole OCR and Word stage!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 605 ✭✭✭PaddyTheNth


    Notepad++ (free) will do this if you do a Replace

    79341614sw8.png

    I can't help thinking that there must be a better way to go about this though.


    E: gj Thoie


  • Registered Users, Registered Users 2 Posts: 2,191 ✭✭✭Feelgood


    Jasus Thoie,

    Top notch stuff!

    Gadget you owe Thoie several pints me thinks....


  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    I'm having more thoughts (instead of making dinner!).

    Is there anything at all that distinguishes the cameras in the file names?

    So, say you might have:

    C1File001.wmv (camera1)
    C2File001.wmv (camera2)
    C1File002.wmv (camera1)


    If so I can write a DOS batch file quickly enough that will grab the filenames you want without having to use the OCR.


  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Thoie wrote: »
    Well, if you have Excel, I'm going to assume you have Word, and I've created a macro for you to do what you want.

    Sub ColumnToList()
    '
    ' Macro to convert column of file names to a list
    ' Macro created 03/02/2009 by Thoie
    '
    
    ' Start by clearing everything in the find/replace boxes 
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
    
    ' Find the end of each row
            .Text = "^p"
    
    ' Replace with a comma thereby putting things on a single row
            .Replacement.Text = ","
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    

    If you're not familiar with macros in Word, open a blank document. Press ALT-F8.
    Type "ColumnToList"
    Press "Create"
    Delete everything you see in the box that appears.
    Paste my code in that box
    Close until you see the blank Word doc again.

    Now paste in your list of files, hit ALT-F8 and "run" the ColumnsToList and it will do it all for you. If you know about macros already, assign the macro to a toolbar button for future use. If not, go read up on macros and assigning shortcuts/buttons to them :)

    I still think if we could see a screenshot of the way the DVR is storing things we could probably work out a DOS batch file to find what you want, thereby skipping the whole OCR and Word stage!

    Excellent work Thoie.

    I really appreciate your efforts :)

    No I'm not familiar with macros in Word but was able to follow your great instructions & it does exactly what it says on the tin.

    I will get a screenshot of the way the DVR is storing things tomorrow & post back.

    Anything that will make retrieval easier will be very much appreciated too.

    Thanks a million for taking the time to help Tohie & everyone else too.

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Thoie wrote: »
    I'm having more thoughts (instead of making dinner!).

    Is there anything at all that distinguishes the cameras in the file names?

    So, say you might have:

    C1File001.wmv (camera1)
    C2File001.wmv (camera2)
    C1File002.wmv (camera1)


    If so I can write a DOS batch file quickly enough that will grab the filenames you want without having to use the OCR.


    I'm not sure but I will check it out for sure & post back.

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 5,112 ✭✭✭Blowfish


    Right so I created a version using batch and vbs. :)

    First part is the batch, just double click it to begin. The batch basically just takes the input, turns it into a single line and adds the comma(s). Once you've pasted the filenames in, press '\' and enter so it knows there's no more input to come. Copy paste the code below into notepad and save it as a .bat
    @ECHO OFF
    
    echo Enter File Name List:
    :loop
    SET /P tempstring=
    if %tempstring%==\ goto cont
    SET string=%string%%tempstring%,
    goto loop
    
    :cont
    cscript Search.vbs %string%
    
    The last thing the batch does is kick off the vbs and gives it the formatted text.

    The vbs then opens up explorer search, enters the details you are looking for and kicks off the search. This means you don't have to bother copy+pasting a second time. You will need to edit the line with 'C:\Program Files\Camera Files\' to be the folder where all the videos are stored.

    The one major flaw with the vbs is that it assumes you are using XP and the default search options. If you aren't, let me know and I'll explain how to edit it to what you want. Copy the code below into notepad and save as Search.vbs. Both the batch file and Search.vbs should be saved in the same folder.
    Dim objShell, WshShell
    
    CreateObject("Shell.Application").FindFiles
    with CreateObject("WScript.Shell")
    do until .AppActivate("Find: All files") or _
    .AppActivate("Search Results")
    wsh.Sleep 500
    
    Loop
    if .AppActivate("Search Results") then _
    wsh.Sleep 2000
    .Sendkeys "{Tab 2}{enter}" : wsh.Sleep 200
    .Sendkeys WScript.Arguments.Item(0) : wsh.Sleep 200
    .Sendkeys "{Tab 2}C:\Program Files\Camera Files\" : wsh.Sleep 200
    .Sendkeys "{Tab 5}{enter}"
    end with
    


  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Excellent Blowfish,

    This is really bringing out the best in you guys, It's just getting better & better.

    I've upped a little Vid of your Batch & Scrip files in action.

    VIDEO

    Now I have to check Thoies idea to see if the cameras are identified in any way within the DVR software file list & post some screen shots.


    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Blowfish,

    I'm getting really lazy now but......

    Is there a way to eliminate the hitting of the return key & typing the backslash?

    Could it run so as it opens the search automatically after the paste or by just hitting the return key?

    Or does the script need that \ as a pointer to say it's done?

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭Thoie


    if %tempstring%==\ goto cont
    Blowfish,

    I'm getting really lazy now but......

    Is there a way to eliminate the hitting of the return key & typing the backslash?

    Could it run so as it opens the search automatically after the paste or by just hitting the return key?

    Or does the script need that \ as a pointer to say it's done?

    -


    I'll randomly answer on Blowfish's behalf, and say "not in its current format"

    The line

    if %tempstring%==\ goto cont

    is saying that it has to keep looping around until it hits the \

    As you're pasting each line into the black box, it's automatically hitting return after each line, though you don't see that. So without telling it when the list is finished it couldn't tell otherwise.

    Is the Player V1.12 in the video your DVR software? I can't quite read it well in the video (damn my aged eyes). If it is, then I'm a bit confused about the need to do a Windows search for them - in that window they appear to be in order by date and time stamp. So, say you're looking for something that happened on Tuesday around 11pm, could you not just click the "Play MMV" button on the files around that time?


  • Registered Users, Registered Users 2 Posts: 5,112 ✭✭✭Blowfish


    Blowfish,

    I'm getting really lazy now but......

    Is there a way to eliminate the hitting of the return key & typing the backslash?

    Could it run so as it opens the search automatically after the paste or by just hitting the return key?

    Or does the script need that \ as a pointer to say it's done?

    -
    Does the OCR always print that exact same extra line of text? If so, you can change the line Thoie mentioned to this (note the extra quotation marks at the start):
    if "%tempstring%"=="*** What's in the status line? Write to us ***" goto cont
    
    That way you'll just have to press enter :)


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Blowfish wrote: »
    Does the OCR always print that exact same extra line of text? If so, you can change the line Thoie mentioned to this (note the extra quotation marks at the start):
    if "%tempstring%"=="*** What's in the status line? Write to us ***" goto cont
    
    That way you'll just have to press enter :)

    If you mean the line at the end of the paste into the batch file?

    That's only there because the OCR is a trial but once purchased that will not be there. :(

    I think I've noticed one limitation to this method but I'm nearly sure it's a Windows limitation??

    It appears that the string of text that gets put into the Windows search box is limited to 20 entries :eek:

    If I paste in 20 items it finds 20 but if I paste in more than 20 it still only returns 20 finds.

    While I can live with this, it's just that there will be occasions where the need to pull more than 20 snippets will arise I'm sure. (I can always run the script twice :) ).

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Thoie wrote: »

    Is the Player V1.12 in the video your DVR software? I can't quite read it well in the video (damn my aged eyes). If it is, then I'm a bit confused about the need to do a Windows search for them - in that window they appear to be in order by date and time stamp. So, say you're looking for something that happened on Tuesday around 11pm, could you not just click the "Play MMV" button on the files around that time?

    Yes you could play the files Thoie but the problem is that on occasion there can be requests to provide certain footage on standard DVD format for analysis, so the files need to be extracted & burned to DVD.

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 8,435 ✭✭✭Gadgetman496


    Blowfish wrote: »
    Right so I created a version using batch and vbs. :)


    The one major flaw with the vbs is that it assumes you are using XP and the default search options. If you aren't, let me know and I'll explain how to edit it to what you want.


    Hi again Blowfish.

    I have XP Pro the machine I'm testing this out on but may need to use it on Vista or even Linux at some stage.

    Any pointers on what section needs to be edited & the steps would be very helpful.

    It's not urgent or anything but I like the setup & want to be able to use it on the other OS's.

    Thanks, Gman.

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Advertisement