Author Topic: Video formats  (Read 1650 times)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 4218
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, MacBook Pro (Mid 2009)
Need to tweak the 'sed' string (Re: Video formats)
« Reply #15 on: July 12, 2017, 11:55:20 PM »
Dear X-Air and WeatherCat explorers of the wild world UNIX utilities

I think this script can be expanded to do the trick.
Code: [Select]
tell application "Finder"
set filename to name of (thisFile as alias)
set filename to (do shell script "echo " & quoted form of filename & " | sed 's/^[0-9_-]*//'")
set name of thisFile to filename
end tell

That isn't going to do exactly what you want for reasons I'll explain in a minute.

Need to learn more about the "echo" command.

echo does what it says, it echoes back the string that has been given to it to "standard out" (in the UNIX lingo.)  Here is the man page if you are curious:

https://ss64.com/osx/echo.html

Some details I need to work on:
  • Automatically change the name of the converted file to a 'generic' name like WC does for the hourly vids. I think that should be relatively simple with AppleScript. I'm thinking just (a) delete the previous vid and (b) remove the "_Hr_Mn" part of the new one.

The sed command that you have is removing numbers underscores from the front of the string, instead of the back.  So it won't do what you want.

sed is an extremely complex program.  Here is the man page for it:

https://ss64.com/osx/sed.html

My UNIX shell use is very rusty but with a some searching on the web this seems to work for what you want:

Code: [Select]
tell application "Finder"
set filename to name of (thisFile as alias)
set filename to (do shell script "echo " & quoted form of filename & " | sed 's/[0-9_-]*$//'")
set name of thisFile to filename
end tell

Do let us know if this finally accomplishes your objectives!

Cheers, Edouard  [cheers1]


Blicj11

  • Storm
  • *****
  • Posts: 2402
    • EW3808
    • KUTHEBER6
    • Timber Lakes Utah
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP™ Data Logger | iMac (late 2013), 3.5 GHz Intel Core i7, 24 GB RAM, Sierra | Sharx SCNC2900 Webcam | Supportive Wife
Re: Video formats
« Reply #16 on: July 13, 2017, 12:49:41 AM »
I think I can 'encourage' WC to simply upload the vid every 60 minutes by pointing to the file name as an "Additional Files" entry. The only problem is that I have no way to ask/tell WC when to do that. I assume (as dangerous as that may be!) that the 'timer', for any item in the "Additional Files" list, starts when one completes/edits an entry for that item. Perhaps they all start again when the last entry/edit is made? I'll check The Manual! [lol]

Additional Files is for uploading files that have to be updated more often than the interval you have set in Main files. If you set an interval in Additional longer than than the one you have in Main, it will ignore the longer one. However, I think that assumes that all of these various files to be uploaded are in the "upload" directory. I've never tried to upload a file from some other folder in the Additional Files. Let us know if this works.
Blick


xairbusdriver

  • Storm
  • *****
  • Posts: 1644
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless w/remote wireless Anemometer Kit
Re: Video formats
« Reply #17 on: July 13, 2017, 05:17:22 PM »
It's been another very busy day, kept me away from the computer too much! I was about half through 'composing' this and now see that another post got ahead of me. First things first...  :)

Edouard,
I'm aware of what the AS is doing, but it should be simple to delete the underscores and numbers anywhere in the name/text. The script should be simpler since the name/text is always the same length and the part I want to delete is always in the same place. ;)

Blick,
Thanks for pointing the limitation of what WC uploads. At least I know it won't be an "Additional file", DOH!! The converter app can place the file anywhere I choose, but I'll have to review The Manual to confirm that WC could upload it at all. I already did an SFTP upload of a file with Automator...  :)

The converter app has been running for about 36 hours without a problem. I am too busy today to do any testing, but will see what happens with a Folder Action that simply uploads when 'seeing' a new addition to a folder. I hope it simply looking for the OS Event and not be 'confused' that one file is replacing another one (from 24 hours ago). If that simple task can be done, I can just SFTP the file and change the name on the server with php. As a matter of fact, since php is already installed in OS X/10, I could just use it on the file on the mini! It has PHP 5.5.38 installed 10.11.6 while I have 5.6.30 with macOS 10.12.5

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 4218
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, MacBook Pro (Mid 2009)
The sed command works on command line (Re: Video formats)
« Reply #18 on: July 13, 2017, 11:53:16 PM »
Dear X-Air, Blick, and WeatherCat tinkerers,

Edouard,
I'm aware of what the AS is doing, but it should be simple to delete the underscores and numbers anywhere in the name/text. The script should be simpler since the name/text is always the same length and the part I want to delete is always in the same place. ;)

I tested the sed command that I gave you on a UNIX command line and it removed the trailing part of the filename as you were seeking.  So with any luck at all, I've solved that problem and you should be good to go with respect to getting the filename without the hour and minute stamp.

Cheers, Edouard

xairbusdriver

  • Storm
  • *****
  • Posts: 1644
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless w/remote wireless Anemometer Kit
Re: Video formats
« Reply #19 on: July 21, 2017, 08:57:33 PM »
I was browsing through my files on my weather site space and noticed a collection of video's. They were all uploaded just a short time before I saw them. My first thought was, "Why are they here?" My second was, "How did they get here?"

A couple of days this week, I also got an email from WC warning that things were falling off the FTP train. "Files are being generated faster than they can be uploaded..." I didn't think much of those warnings until I saw those fairly large video files (24 on each upload!).

Even though I have a certificate claiming I have a degree in Accounting, I hadn't been able to put two and two together until seeing the extra files and the warnings.

While I can't use the "Additional Files" function to upload these vids, one can, even if accidentally, upload just about anything one might want by simply putting them in a certain folder. My WC prefs/On-Line->Main->Set HTML Source is a particular folder on the mac mini. I'm sure everyone else, with a website, has a similar path there. The fact is, that folder is exactly where I had told the converter app to place its converted QuickTime movies! WC then, dutifully Uploaded the html files, text, php AND the MP4 files for me.

I changed the settings in the video converter app as that's just wasting bandwidth and storage space plus adding to the workload of WC. I have just verified what is probably in The Manual about this behavior. I created three useless little files, placed them in the WC Prefs specified folder and saw them uploaded to my web space in a few minutes. Those 24 video files were uploading every two minutes, in my case. No wonder WC was complaining about its FTP workload! cmu:-) Sorry, Cat, it's my fault! [blush]

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 4218
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, MacBook Pro (Mid 2009)
Oops! (Re: Video formats)
« Reply #20 on: July 21, 2017, 11:50:55 PM »
Dear X-Air and WeatherCat tinkerers who occasionally tinker too much!  :-[

Those 24 video files were uploading every two minutes, in my case. No wonder WC was complaining about its FTP workload! cmu:-) Sorry, Cat, it's my fault! [blush]

Yup, that certainly could be a reason why WeatherCat would be in an FTP overdrive condition!

Glad you finally got to the root of the cause!

Cheers, Edouard