每天,我必须重命名文件以将破折号替换为空格,然后才能将它们发送到我们的机器(我们的一些机器不读取文件名中的空格,但是我们的文件命名约定中有空格,我有利益冲突。知道)。
有时候是一个文件,另一个是六个文件,所以我的方法是使用Windows Send To菜单将选定的文件发送到脚本。
我已经重命名了字符串,但是实际的move函数说到fso.movefile函数时找不到路径。
这是我到目前为止所拥有的。
library(shiny)
library(ggplot2)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("A","Test",choices=c(1,2,3)),
actionButton("go","GO")
),
mainPanel(
plotOutput("graph1"),
tableOutput("table1")
)
))
server <- function(input, output) {
test<-function(A){
C<-(1:3)
A<-as.numeric(A)
dfA<-data.frame(A,C)
colnames(dfA)<-c("var test 1","var test (2)")
g1<-dfA
g2<-ggplot(data = dfA, aes(x=`var test 1`, y=`var test (2)`))+
geom_point(shape=1)
outputs<-list("output1"=g1,
"output2"=g2)
}
model_output<-eventReactive(input$go,{
test(input$A)
})
output$graph1<-renderPlot({
model_output()[[2]]
})
output$table1<-renderTable({
model_output()[[1]]
})
}
shinyApp(ui = ui, server = server)
任何帮助将不胜感激。
答案 0 :(得分:0)
所以我的问题是我所在的文件夹也有空格。所以我的代码试图将其重命名为一个不存在的文件夹。
一旦我从路径中解析出文件名并重新分组了修改后的文件名,它就可以很好地工作。下面的代码。
Dim t ' original file and path
Dim s ' file name only with spaces
Dim u ' new file name without spaces
Dim v ' path only
Dim obj
Set objArgs = WScript.Arguments
set obj = WScript.CreateObject("Scripting.FileSystemObject")
'Cycle through files
For I = 0 to objArgs.Count - 1
' Assign array entry to variable
t = objArgs(I)
' Parse file name from path
s = Right(t, Len(t) - InStrRev(t, "\"))
' Remove file name from path
v = left(t, InStrRev(t, "\"))
' Parse variable to replace spaces with dashes
u = Replace(s, " ", "-")
' ' Let me know how I did
' WScript.Echo "Was(t): " & t & vbcrlf & "Is(s): " & s & vbcrlf & "Path: " & v
'Move 'em
obj.movefile t, v & u
Next