I'm trying to delete all images within a folder taken between 8pm and 7am Using Powershell but I'm having some trouble. Unfortunately the information on the images do not have the correct date modified/ date created time but the correct time is stored in the image metadata as Date Taken.
I've tried this
get-ChildItem *jpg | Where-Object{$_.LastWriteTime.TimeOfDay.Hours -gt 20 -or $_.LastWriteTime.TimeOfDay.Hours -lt 07} |Remove-Item
But this deletes everything because the write time is 11pm for all the images. (the image taken date is different for the images)
I have about 3,000 images to sort through. I'm very new to powershell, but it seems like it should work. I can also use Python if people think thats easier...
You need to read the EXIF data (metadata) from inside each image file. Get-ChildItem is only going to return the properties of the file itself, not any metadata inside the file.
Checkout this Microsoft article that describes the process using a COM object to expose the EXIF fields of an image (including Date Taken). This solution requires a PowerShell function on the technet gallery to actually fetch the EXIF data.
I ended up finding another code that assigns the Date Taken to the Date Created property. So then I could run the original code I posted. I dont really need anything efficient so this got the job done.
Set EXIF DateTaken as file CreationTime
I have added custom column to store company logo. I have used file api of moodle like :
$mform->addElement('filepicker', 'certificatelogo', 'Company Logo', null,
array('maxbytes' => $maxbytes, 'accepted_types' => '*'));
$mform->setDefault('certificatelogo', '0');
$mform->addHelpButton('certificatelogo', 'certificatelogo', 'certificate');
Once the form is submitted itemid will be stored in custom column. Say "648557354"
Now I need to get image to print logo on certificate. How can I get image path from itemid? Do I need to store any other information to retrieve image?
The itemid returned is the temporary id of the draft area where the file is stored whilst the form is being displayed. You need to copy the file into its 'real' location, when the form is submitted, otherwise the file will be automatically deleted after a few days (and it will only be accessible to the user who originally uploaded it).
I'd always recommend using the filemanager element, if you are planning on keeping the file around (filepicker elements are for files you want to process and discard, such as when uploading a CSV file data to parse and add to the database).
Details of how to use it are here:
https://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#filemanager
But the basic steps are:
Copy any existing files from the 'real' area to the draft area (file_prepare_standard_filemanager).
Display the form.
On submission, copy files from the draft area to the 'real' area (file_postupdate_standard_filemanager).
When you want to display the file to the user, get a list of files stored in the file area (defined by the component, filearea, context and, optionally, itemid, you used in file_prepare_standard_filemanager and file_postupdate_standard_filemanager). You can do this with: $fs = get_file_storage(); $fs->get_area_files().
For those files (maybe only 1 file, in your case), generate the URL with moodle_url::make_pluginfile_url.
Make sure your plugin has a PLUGINNAME_pluginfile() function in lib.php, to examine incoming file requests, do security checks on them, then serve the file.
There is a reasonable example of all of this at: https://github.com/AndyNormore/filemanager
I create a workflow, and when I go to the task-edit page:
I'm trying to obtain the nodeRef of the file (latexexemplo-2.pdf) of the workflow task:
http://localhost:8080/share/page/task-edit?taskId=activiti$20649
I'm trying to make this way:
var taskId = args.taskId
var task = workflow.getTaskById(taskId);
nodeRef = task.getPackageResources()[0].nodeRef;
But I obtain "args is not defined" ... "workflow is not defined" ... "task is not defined".
How can I get the nodeRef with another way?
Unfortunately, you cannot access in the browser information that is in the repository.
A quick and dirty solution is to use directly the information that is already in the page.
I have started a workflow and opened the task page as you did.
Using the browser debug tool, I have inspected the html.
As you can see in the image attached below, Alfresco stores the documents attached to the task in an hidden input. You could use YAHOO to get it.
Search for an element with the id "page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems".
If there is more than one document associated, the value will be a comma separated list of noderefs. I am getting the first element. This of course works, as is, only if there is one and only one document associated. You should probably take into account also the case when no document is associated or there is more than one.
var nodeRef = YAHOO.util.Selector.query("#page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems")[0].value;
You can get all the current task details which are assigned to you by using
Workflow API in Freemarker.
So you can get the task id or noderef of tasks.
How can I get the file name of an image from a SharePoint 2013 Asset Library?
I am trying to write a JQuery/REST snippet to search a subset of images within the library, based on their other column values and display them. I would use FileLeafRef in case of a Document Library, but I couldn't find an equivalent field in Asset Library.
I so far tried the following, neither returns file name:
https:///crm/_api/Web/Lists/GetByTitle('Publication%20List')/items?select=File/Name&expand=File
https:///crm/_api/Web/Lists/GetByTitle('Publication%20List')/items?select=FileLeafRef
There is a typo in your example, in particular $ symbol is missing for $select and $expand query options (more details).
The following rest endpoints demonstrate how to retrieve file name from Assets library:
1) Using FileLeafRef property:
/_api/web/lists/getByTitle('<list title>')/items?$select=FileLeafRef
2) Using File/Name property:
/_api/web/lists/getbytitle('<list title>')/items?$select=File/Name&$expand=File
3) Using Folder/Files property:
/_api/web/getfolderbyserverrelativeurl('<list url>')/files?$select=Name
I believe that yt's still FileLeafRef for an Asset Library. Any chance you could put the relevant code in your question?
Here's the rest endpoint for FileLeafRef:
/_api/web/lists/getByTitle('<list title>')/items?$select=FileLeafRef
Alternatively you could always use the File Name property:
/_api/web/lists/getByTitle('<list title>')/items?$select=File/Name&$expand=File
I don't even know if the title for this question is appropriate, since I'm really lost and need some advice, a starting point to what I need to accomplish.
My iPhone app plays audio streamed from the Internet, with my custom made player. Some links are live streams from Akamai and others are audio files stored on a website. I'm OK with the live streams, but my problem is with the audio files.
As I have many stored audio files that the user can choose from, in different languages, and I don't want to hardcode all of them on my application.Then I need a clever way for the user to browse on the app (pushing the information from the Internet) until he reaches the desired file to play.
The website is organized like this:
First there is list, having all available programs. The user chooses the desired program, then another page shows up and he has to choose a day of the week to play.
My question is: how can I parse this content, with programs and days of the week to choose from? Should I look into HTML parsing? Is there a better/simpler way, like making XML files on the website?
If this helps, the all the webpages end with the .aspx extension.
Please, any advise from a more experienced programmer will greatly help me. Thank you!
I don't think parsing HTML would be the best implementation here. Go for a structured source that doesn't have viewable markup to worry about parsing out or ignoring altogether (also will mean fewer resources thrown at parsing the markup because you will only be parsing what matters).
I'd suggest consuming an XML or JSON source that can be converted to a NSDictionary or other data structure for app use. Here's a neat little class that converts an XML source to an NSDictionary: http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/
TBXML is another light-weight XML parser for Objective-C that makes implementing a custom data object up to you: http://www.tbxml.co.uk/
If you'd rather use JSON, there are a number of helpers out there. A good place to start looking would be here: http://cocoaobjects.com/?s=json
If I have understood your question correctly, whatever source you choose, you're likely to want to wind up with a dictionary object that looks something like this:
programs = (
{
program_name: "Foo";
tracks = (
{ day: Monday;
track: audio_file1.mp3;
},
{ day: Tuesday;
track: audio_file2.mp3;
},
{ day: Wednesday;
track: audio_file3.mp3;
}
);
},
{
program_name: "Bar";
tracks = (
{ day: Monday;
track: audio_file4.mp3;
},
{ day: Tuesday;
track: audio_file5.mp3;
},
{ day: Wednesday;
track: audio_file6.mp3;
}
);
},
{
program_name: "Baz";
tracks = (
{ day: Monday;
track: audio_file7.mp3;
},
{ day: Tuesday;
track: audio_file8.mp3;
},
{ day: Wednesday;
track: audio_file9.mp3;
}
);
};
);
Once you've worked out your data source, and converted it to a native data object for working with in Obj-C, you should be able to proceed with coding up a UI that can iterate through the dictionary to provide a list of programs and, in turn, a list of days for each program with accompanying audio files to select to play.
I had a similar need. Consuming data from an ASP.NET site. In the end I used JSON from the .NET side and return JSON. Then, I used the json-framework from Google Code to convert the JSON returned to an NSDictionary. From there the rest is history.
If you are using .NET MVC, then returning JSON results is super simple in a controller. Since you have aspx extensions, I assume that is not the case. There are tons of JSON parsers for C# listed at the bottom of the json.org homepage.
if the website content is static, I would hard code the file names and appropriate URL's to your server within the app and let the user scroll through the list of available items.
if the website content changes, then I would create an XML file on a server which your app downloads on launch (or as you deem fit) and parse within the app, then continue as per static content.
hope this starts you off in the right direction.
Think outside the box: use UIWebView
How about instead of thinking how to parse data and then write UI code to display it we think more of the big picture: we want to present to iPhone user sequence of screens to select and play a recording, and this should be coming from a web server. Only if there was such a tool... but wait, there is! It's called web browser and in the form of UIWebView you can integrate it in your interface, with a little twist.
First, adding UIWebView is very easy, check this http://zpasternack.blogspot.com/2010/09/stupid-uialertview-tricks-part-i.html for illustration.
So let's say we added web view and user can select an audio file from there, what happens then? Turns out you can tell it what should happen, check this question UIWebView open links in Safari . You can hook your code into handling of link clicks and do whatever you please (like hide web view and show player etc).
To give an example, say first in the web view you load
http://foobar.com/somepath/listOfPrograms
which happens to be web page showing list of the programs (which thanks on some clever CSS could look just like an UITableView if you please). User clicks on a programing name, that goes to
http://foobar.com/somepath/programs/CarTalk
which page presents list of weekly shows (again iPhonesque formatted) and when clicked on a link, this now points to
http://audio.foobar.com/somesuch/45678913.mp3
at which point your code recognizes that's audio URL, apprehends control and plays it however it pleases.
How useful is that you may wonder. The answer is "very" :-). It moves the presentation structure away from the app - and to the web server. The app's entry into the UIWebView is the initial URL and the exit is click on audio file link. In a few months someone decides they want the choices not to be made fist programming name and then day of the week; or add additional layer of choice by language or country. No problemo, no need to release new version of the app, just tweak a bit the web pages on the server and the app will pick it up automagically.
It also makes testing the web server side easy - just point any browser to the initial page URL and click-through to see if you make it to a viable audio file. The web master can handle that independently of you, the app writer. You don't even have to care what they use on their side to get those pages, is it hard-coded in html, or comes from a SQL DB, XML tarpit, whatever.
If it were me, and assuming I have some clue as to what you're talking about, I would have a database that shows the relationship between the audio content and the date. Then your spinner for the content would just be updated by a query...
So, for instance, assume a table
+----------------------------------------------------------------------+
| Filename | Language | Date |
+----------------------------------------------------------------------+
| kjslfiewofksalfjslfakj | Swahili | 2011-11-01 |
| shfaahflajfewifhlanfww | Guyanese | 2011-10-08 |
| weijalfjlajfljalsfjewn | French | 2011-11-01 |
| fiwojancanlsjfhkwehwlk | Swahili | 2011-11-01 |
| fhalksflwiehlfnaksflhw | Swahili | 2011-11-03 |
+----------------------------------------------------------------------+
Okay, so if joe schmo reaches the page for the show dated 2011-11-01 and his language is Swahili, two rows will be returned:
+----------------------------------------------------------------------+
| Filename | Language | Date |
+----------------------------------------------------------------------+
| kjslfiewofksalfjslfakj | Swahili | 2011-11-01 |
| fiwojancanlsjfhkwehwlk | Swahili | 2011-11-01 |
+----------------------------------------------------------------------+
You could also easily add references for the date and language that indicate an Akamai record. It doesn't strike me as terribly complicated, but it may mean significant redesign for you. However, you've been purposefully vague on details, so hopefully at least this points you in a right direction.
Edit:
Alright, so after re-reading, there may be a relatively easy way to control content in its organization by using directory structures, but it takes a backseat to my proposed table.
As I understand it, there are potentially three categories at work: program, date, and language.
If I create a file structure (assuming root):
/public_html/audio/[date]/[language]/[program_name].mp4
Then, when the user selects a date and language, we might have:
/public_html/audio/2011-11-14/swahili/the_linux_show.mp4
Then, all we'd have to do is have the $_POST data from the selectors read to provide the show... Unfortunately, this will mean that we have to know the date that the show aired, then language, then show name. This would be a far worse way than a database, but could be done. Use ASP to read directory contents and you can list using loops. Seems pretty simple, but not at all elegant.